add extra description field to file upload primefaces - jsf

I use the primesfaces p:fileUpload tag, witch works fine. But I need to be able to ad a description to the files I upload. How can I do this?
I added a textfield on my page and assigned it to a bean property. But how Can I update it when pressing the primefaces upload button? (The fileUpload is ajax, so not the entire form is submitted. I don't want to submit the whole form because I don't want validation errors when uploading files)
Or should I need to use another tag (other library)?
Roel

Related

JSF wont let me put action in form tag

JSF do not let me to put action url in my form when using <h:form>. It is advised to use plain html - <form> tag. But that won't save bean values in form in database. What is the use of that, obviously JSF creators know, I certianly don't.
It's possible to set url with command button. But, my Command button has method names - so it can't point to urls. How to set it easy?

Can Primefaces dialog framework display xhtml from an external domain?

when I read about the Primefaces Dialog Framework (DF), which is "used to open an external xhtml page in a dialog", I assumed this meant you could display xhtml from another domain.
If this is the case, how can I give an absolute url to the method...
requestContext.getCurrentInstance().openDialog(outcome)?
These don't seem to resolve.
If this is not the case, then what is the purpose/advantage of the DF? If I can only display xhtml from within the same app, why not just use the declarative <p:dialog> component? It can be put inside a <ui:composition> if you want to reuse a dialog from multiple pages, for instance.
OpenDialog enables the page author to open an xhtml referenced via a JSF navigation outcome in a dialog, the options are the configuration attributes for dialog like modal, draggable and finally the optional params are the view params to pass parameters to the dialog.
Actually the PrimeFaces blog entry referring to that means to use an internal application view outcome for the dialog to refer to. That bounds the path to your application JSF navigation cases.
Then what's the advantage of the dialog framework? I would say, bringing you the ability to specify the outcome and the dialog attributes at runtime. Let's say you have a car table, where you open a detail dialog when user clicks on one row. Suposing you need to display different content depending on car's branch, it would be easy to control what is going to be rendered inside the dialog:
String outcome = "dialogs/genericCar";
if (car.getBranch.equals("Ferrari")){
outcome = "dialogs/ferrariCar";
}
else if (car.getBranch.equals("Aston Martin")){
outcome = "dialogs/astonCar";
}
RequestContext.getCurrentInstance().openDialog(outcome);
Doing that would be so clean an straight forwarded. Otherwise with the classing p:dialog tag you're limited to a single dialog with conditional rendering inside depending on the content you want to display.
The chance of being able to change the dialog attributes depending on what you want to render seems interesting too.
See also:
PrimeFaces Dialog Framework
Blog entry

Xpages File Upload Control does nothing

Background: One xpage bound to document1. On this xpages is a tabbed table contain several tabs. Each tab contains an panel bound to other data sources incl document2. Document2 is created and made a child of document1. In each panel is a table to allow the user to create the new document, as well as two view controls. Everything works beautifully...until...
Problem: I was asked to add a way to upload an attachment to the child document. I first created an rich text field on the bound document called "ScannedInvoice". I then create a File Upload Control from the core controls and bound it to document2/ScannedInvoice. By rule, I only want a single attachment, otherwise I would consider the openNTF upload control.
I cannot figure out why nothing appears on the back end when I upload a file and create a new document. Everything else works, but there is no attachment in the ScannedInvoice field and also no $FILE fields attached to the document either.
Thanks in advance for any tips. I have searched quite a bit and have not found any answers. - Steve
<xp:fileUpload id="fileUpload1"
value="#{document2.ScannedInvoice}" useUploadname="false"
style="font-size:8pt" filename="scannedinvoice.jpg"
mimetype="image/jpeg">
</xp:fileUpload>
Note: The field ScannedInvoice on the Invoice form is rich text.
Code to save button: document2.save()
Document2 has scope=request and ignoreRequestParam=true. Both of these have to be set like this in order to work. parentID=# document1.getNoteID()
a file upload needs a full refresh of the page to be able to upload the file. Make sure that you are doing that.
======================================
Update Domino 9.0.1 supports partial refresh uploads

multiple file upload handling with backing bean

I have a page with a file upload input from tomahawk's components. I want to know if putting 5 upload inputs with a single button those will be sent as part of the form.
And I want also some ideas on how I can make my managed bean to adapt for this multiple file upload.
Thanks in advance.
I think you can just simply map each file to different variables in your backing bean. When the user clicks submit button, you can get all your files from these variables at 1 go.
PrimeFaces' upload component manages multi-upload.

add the code for a widget (widget.xhtml) once but use it twice in same webpage, possible ? How?

I have a widget in my application that I need to display at two places(once in main page body and once through dialog box). Currently its code has been added twice in the page. Now I was thinking, If there was a way I could just include it only once and show the same instance in the dialog box, as in the main page body.
Can you suggest a way for this?
I'm Using:-
JSF 2.0 with Facelets
Primefaces 3.0 M3 Snapshot
JSF 2 has exactly the feature you want: it's called composite components. I bascially allows you to write a bunch of Facelet code into a file and use it just like any other JSF component, pass parameters to it, etc.

Resources