Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

JavaServer Faces: ValueChangeListener doesn't write back to textfield

Thread view: 
Michael Plate - 13 Apr 2007 21:32 GMT
hello people,

i have an problem and as newbie of javaserver faces i couldn't solve this.

my jsf page have two textfields (textfield1 and textfield2) and i write a
new value at textfield1 and the valuechangelistner should calculate this and
write it back to textfield2. at moment the valuechangelistener works fine,
but i can't write the result of calculation in textfiled2

I couldn't find a similary problem at google. I get many results of
selectOneMenu, but nothing about my problem.

my JSP with JSF-Tags:

<h:inputText  value="#{bean.textfield1}"
valueChangeListener="#{bean.textfield1Changed}"
onchange="this.form.submit()"
id="textfield1" converter="javax.faces.Float" size="80">

<h:inputText  value="#{bean.textfield2}"
id="textfield2" converter="javax.faces.Float" size="80">

my javabean:
public void textfield1Changed( ValueChangeEvent event) {
   float newValue=((Float) event.getNewValue()).floatValue();
   // ... calculate newValue and output will back to textfield2

   //at this point i haven't an idea to write back
}

Have anyone a idea to resolve my problem.

thank you very much for an answer.

best regards
Michael Plate
SadRed - 14 Apr 2007 00:04 GMT
> hello people,
>
[quoted text clipped - 33 lines]
> best regards
> Michael Plate

Try immediate="true" for the first h:inputText
Michael Plate - 14 Apr 2007 11:30 GMT
hello SadRed,

many thanks for your answer. :-)

immediate="true" doesn't solve my problem. the effect is same as without
immediate="true". my main problem is to write an value back to textfield2.
this shall happen in bean.

i try out with FacesContext.getCurrentInstance(), but i doesn't find
component 'testfield2'. :-(

best regards
Michael

>> hello people,
>>
[quoted text clipped - 38 lines]
>
> Try immediate="true" for the first h:inputText
SadRed - 15 Apr 2007 00:22 GMT
> hello SadRed,
>
[quoted text clipped - 52 lines]
>
> > Try immediate="true" for the first h:inputText

I forgot to mention that value change listener is
called in the Process Validation phase of JSF
life cycle. So, in your JSF view, immediate should
be false for tf1 and tf2 value update should be
done by calling setValue() method of the component.
And the last line of the listener should be:
facesContext.renderResponse() call.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.