File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes getCurrentValue() returning an old value! a4j and JSF 1.2. Help needed ASAP! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "getCurrentValue() returning an old value! a4j and JSF 1.2. Help needed ASAP!" Watch "getCurrentValue() returning an old value! a4j and JSF 1.2. Help needed ASAP!" New topic
Author

getCurrentValue() returning an old value! a4j and JSF 1.2. Help needed ASAP!

Ravi Chilakapati
Greenhorn

Joined: Apr 20, 2010
Posts: 10
Hi.
We have our own set of custom components tightly coupled with the mojarra implementation of JSF 1.2. And these components were ajaxified some time back.
Now lets say I have a form with a text input field.
<myns:myCustComp id="asdh" value="#{somebean.somefield}" readonly="true"/> followed by an a4j button.
Now lets say that I input some text into it (for eg: MOOSE) and click on the button which basically only submits this text input and re-Renders it(the text input).
So now, the string field somebean.somefield has been set to MOOSE. We go through the usual motions, and when the page is ready we do the same thing again, except that we now enter a new value in the text input (for eg. SALOON).

WHAT SHOULD HAPPEN WHEN BUTTON IS CLICKED:
The field somebean.somefield should be set to SALOON. Also, the component should get updated with its value set to SALOON. Page should re-render (ajax!) with text input showing SALOON.

WHAT IS HAPPENING:
The field somebean.somefield is being set to SALOON. The component's value is still MOOSE. Page re-renders with text input showing MOOSE.

I initially thought it was because of the readonly="true" attribute. So I set it to false, and later removed it totally. And yet, the same behaviour continued.
Then I thought that something was wrong with the renderer of the custom component. But it was and still works fine for most of the other pages - both ajax and non-ajax!
And there is not one error message through out.


We are using com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue() to extract the latest value in the encodeBegin() of the text input component.
So,
a) Why is the component tree not being updated with the latest values? As far as my understanding goes, that is one of the first things done in the ApplyRequestValues phase of the JSF lifecycle. What kind of scenarios is this possible in?
b) The strange part is that if I have an output label custom component(again our own custom component) right next to the text input field, the output label shows the correct value (SALOON) and the text input component shows the old value (MOOSE) - in the same page, in the same form and same tab!!!. How is this possible?!

I will be grateful if someone can give me a quick and reasonable response!
TIA.
Regards,
Ravi.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getCurrentValue() returning an old value! a4j and JSF 1.2. Help needed ASAP!