views:

626

answers:

2

I have a t:inputFileUpload inside the form, in the html of the display page the id of this component is form:inputFile but when I tried to get the component from the view root using "form:inputFile" the return is null, but when the "form:" is removed the return is the component. The component don't set the value in my managed bean, someone have this problem?

EDIT:

<h:form id="form" enctype="multipart/form-data">
<t:inputFileUpload id="inputFile" size="40" value="#{managedBean.inputFile}"/>
</h:form>

In the managed bean:

    private UploadedFile inputFile;

with the gets and sets provided by Eclipse.

//This method scans the view root and returns the component with the id passed as parameter
findComponentInRoot("form:inputFile");

This returns null, but when I use:

   //This method scans the view root and returns the component with the id passed as parameter
    findComponentInRoot("inputFile");

The return is the component I'm looking for, but when I use the View Source in Internet Explorer the id of this component is "form:inputFile".

I don't know if this is related, but the component don't set the value in my managed bean and it's strange the fact that the id of the component is different from the HTML source. I'm using JSF 1.2 Mojarra. Someone else has this problem? Or know why this happens?

EDIT2: Okay, I'm very stupid, aparently the build wasn't working correctly and when the build was changed to other task from the Ant it worked (still don't know why, but simply worked). Sorry for the trouble.

A: 

I guess findComponentInRoot is this (a minor detail you should've shared).

Anyway, using findComponent(..) or getChildren(..) always return the id of the components as defined in the page. The html id is something different that consists of the naming container:id.

Bozho
i think that what he really wants to know is: why isn't jsf properly setting the uploadFile property in the backing bean?
marcos
findComponentInRoot is exactly the code in the link. My problem in this case is that in some pages it returns with the "formId:idComponent", and in others it returns with "idComponent", I'm not sure if the absence of "form" in the id is related, but this component isn't setting the value in the managed bean.
kenzokujpn
A: 

You should use component binding or UIViewRoot#findComponent(). But that won't solve the problem of the uploaded file not being set. To fix it, first step is to ensure that you definied and configured the ExtensionsFilter properly as per the Tomahawk documentation, since it is the one responsible for parsing the multipart/form-data request and putting all the parameters among with the uploaded file back in the request parameter map, so that the FacesServlet can apply them and update the model values.

BalusC
My co-worker already did this, and in the pages he worked it's working fine, I already get the configurations but in my page isn't working.
kenzokujpn
Debug which phases are been executed and if no validation or conversion errors are been thrown (add `<h:messages/>` to the page to notify them all).
BalusC