aspose file tools*
The moose likes JSF and the fly likes JSF 1, how to fill fields with data from other fields (no javascript)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF 1, how to fill fields with data from other fields (no javascript)?" Watch "JSF 1, how to fill fields with data from other fields (no javascript)?" New topic
Author

JSF 1, how to fill fields with data from other fields (no javascript)?

Darrel Youngblood
Greenhorn

Joined: Aug 27, 2012
Posts: 1
Hey there.

This is what I want to do:
I have an input field where the user can fill in a number which contains information about a the birth date and the gender of a person. I also have an input field for gender and a field for the birth date. When the user fills in the first field the following shall happen: The number gets validated and if it is valid the information about the gender and the birth date will be extracted and the values will be written to the model. Now the other two fields shall be updated and show the values which where set before.

This is what I get:
when entering a valid number, the birth date field is rerendered but it remains empty. When I reload the page the field birth date contains the correct data.

This is what I coded:




This is what i guess:
Since the data in the field birth date is not changed at all from the view side, jsf does not reload the values from the model.

This is my question:
How can I achieve my goal to immediately show the correct/extracted data?

BTW: I'm using JSF 1 , usage of JavaScript should be avoided

Thank You in advance for any suggestions and hints! :-)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Neither Validators nor Converters should be setting backing bean properties. They should only validate and convert. JSF itself will set the backing bean properties - providing that all submitted values are, in fact, valid.

In the event that you want one control to update the value of another control, the instigating control's action method should update the Model (backing bean) property. Once it has done this, the rendered response will reflect the updated bean property automatically. In the case of AJAX updates, of course, you do have to indicate the control(s) that require updating, which you do using the reRender attribute in the case of RichFaces a4j.


Customer surveys are for companies who didn't pay proper attention to begin with.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

BTW, whether you realized it or not, the minute you used a4j, you broke the "no javascript" rule. AJAX is an acronym and the "J" in AJAX stands for "Javascript" - As in Asyncronous JAvaScript eXecution.

Furthermore, RIchFaces pulls in an entire JavaScript library to do its dirty work (jQuery). So, while you may not be doing JavaScript coding explicitly, there's Javascript there.
 
wood burning stoves
 
subject: JSF 1, how to fill fields with data from other fields (no javascript)?