I apologize if I didn't write the message correctly, I am not sure I know how to mark the JSF code here. I really need your kind help as I am stack with something I believed should have been easy but I can't figure out a solution yet.
I have a class called User that has 2 properties name and email.
I have a backing bean JSFBean that has the User as a member (User user).
Now I have a JSF page with the following:
assume that the original values are name: elico and email:elico@email
When I change the values and click save everything works well, but if I click on change and on the backing bean function I am changing the value, e.g. this.user.name="new name" then this is not reflected in the page and still i see on the page the old name.
Isn't there any way that I can change the bean properties on the server side and they will be reflected on the client?
Thanks in advance
Joined: Dec 19, 2010
Sorry, I would like to add that in case I use
In that case after 'change' method was executed I can see the new value. only on the h:inputText the old value remains and not updated.
What you would need is "ajax push" to do this, I know that PrimeFaces has something that
will do this. If you think about what you're saying it is "the user doesn't know their own
name and the server is going to tell them". Whilst there are situations where you may want
to do what you suggest, it is not a valid scenario for name and e-mail I would say.
Select your code and hit the Code button above for format your code excerpts.
I think so the form is not submitted thats why the information is not reflected. Secondly the way you are
calling your bean as
Try to use something like
It will solve your problem hopefully. Hope this helps.
I am aware to your comments for the bad coding conventions, but I just gave an abstract example of what I am trying to do. In my real development I am writing the code correctly. I just wanted to explain in simple words what I am trying to achieve.
Also, the example I gave with user name is not the real, someone answered here that it makes no logic to do so, but agqain, it was only an abstract example to a complex scenario I am developing.
About your input to use
how exactly do you suggest doing it? how is it going to help me?
Thanks in advance.
Joined: Oct 13, 2009
Glad to hear that you are using best practices.
What experience i shared with you was when recently i was writing a picture upload component
using PrimeFaces. My scenario was a drop down list of person documents. For example, Person photo
Passport Picture and on, and as i was using PrimeFaces upload component as soon as i used to click upload
what i wanted was that, that particular picture is stored in the DB as a BLOB with correct document type passed
which was selected from the drop down.
As upload component on click of upload was just firing an event and form was not getting submitted due to
which i was unable to get the document type. I needed someway that on select of document type that value
should be set inside my managed bean, either i had to use valueChangeEvent or something like that to submit
the value, i just used this code which i suggested and in that back-processing, my form was submitted and my
document type was set in the Managed bean. It can be useful in such scenarios.
Joined: Dec 19, 2010
Thank you for your quick reply.
But this is not the problem I am having, since in my case the form is indeed submitted, the only problem is that the values from the inputText field are not updated after the processing of the action listener method.
From what I understand the problem is due to the fact that the JSF phase 'Invoke Application' is called after the phase 'Update Model Values' therefore even if I change the values of the bean during the 'Invoke Application' (action listener) phase it is not reflected in the model.
Though, If I use the following:
Then indeed the outputText shows the correct modified value.
Joined: Oct 13, 2009
I suspect the same. Having strong concepts in JSF Request Processing Cycle is very important
and comes really handy while debugging the bugs. Good luck.
I'm wondering if you solved this problem, because I have the same one.
When my view contains an hutputText it reflects the value of the backing bean when this gets updated,
but if I change the hutputText to an h:inputText it no longer reflects the current value after update.
The page gets resubmitted OK, that's not the problem.