• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

MyFaces - HtmlSelectOneMenu and ValueChangeEvent

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a HtmlSelectOne component on a form. My value-changed listener is not working - never enters the method in the backing bean. I have registered the property in the faces-config.xml:

<managed-property>
<property-name>classIfSelItem</property-name>
<null-value/>
</managed-property>

<h:selectOneMenu id="classification" value="#{form.classIfSelItem}" converter="ItemConverter" valueChangeListener="#{form.processValueChange}"
immediate="true" >
<f:selectItems value="#{list.classifList}" />
</h:selectOneMenu>

And my method:

public void processValueChange(ValueChangeEvent event){
HtmlSelectOneMenu selOne = (HtmlSelectOneMenu)event.getComponent();
System.out.println(selOne.getValue());
System.out.println(selOne.getId());
event.getOldValue();
event.getNewValue();
}

This method never gets entered. Any ideas?
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Smiley:
I have a HtmlSelectOne component on a form. My value-changed listener is not working - never enters the method in the backing bean. I have registered the property in the faces-config.xml:

<managed-property>
<property-name>classIfSelItem</property-name>
<null-value/>
</managed-property>

<h:selectOneMenu id="classification" value="#{form.classIfSelItem}" converter="ItemConverter" valueChangeListener="#{form.processValueChange}"
immediate="true" >
<f:selectItems value="#{list.classifList}" />
</h:selectOneMenu>

And my method:

public void processValueChange(ValueChangeEvent event){
HtmlSelectOneMenu selOne = (HtmlSelectOneMenu)event.getComponent();
System.out.println(selOne.getValue());
System.out.println(selOne.getId());
event.getOldValue();
event.getNewValue();
}

This method never gets entered. Any ideas?



Did you post the form (with a h:commandButton/h:commandLink or javascript)?
if so, did you use a h:messages tag to show eventuals conversion or validation errors?

Mauro.
 
Paul Smiley
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply, Mauro. Yes, this issue is related to the other post you replied to. Same problem, 2 different parts.

Yes, I put this in a form, but did not do the submission - isn't event handling supposed to occur right away, and not at form submission? I set immediate="true" on the component.

But yes, when I do a submit, I do get validation errors. I'm not at work right now, but I believe it has to do with conversion - although the data element and the list contain the same type of object. I've been searching the web for some time to find more details on events in JSF, but can't find much about this.....

Thanks!

Paul
 
Paul Smiley
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"... Error during model data update." is the validation error when I submit the form.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Smiley:
"... Error during model data update." is the validation error when I submit the form.



My guess. Your exception stack trace would be something like IllegalArgumentException in selectItemsIterator().
??
 
Mauro Castaldo
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show all your code (form bean and list bean)?
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mauro Castaldo:
Can you show all your code (form bean and list bean)?



Surely, I am here to help you out mate, if I can. But for code, I'm sorry to say its proprietry.

BTW, you didn't respond to my question. It might be helpful for me to tell you the real reason or solve your problem.
 
Mauro Castaldo
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adeel Ansari:


Surely, I am here to help you out mate, if I can. But for code, I'm sorry to say its proprietry.

BTW, you didn't respond to my question. It might be helpful for me to tell you the real reason or solve your problem.



Sorry Andeel,
I'm Mauro and I'm asking code to Paul!
 
Paul Smiley
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mauro,
Thank you for your time. It was a stupid mistake (aren't they almost always? ) I have a custom component that I used for 2 different types of data and used the same converter - therefore my conversion back to object failed. I wrote another converter and all is fine. I'll probably clean them up at some point to get the source and then do a runtime comparision to find out what the data is and reuse the converter for type, but a second converter gets me over the hump for right now. I did write it down for my next refactor...

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
two ways we have here
One is here described below and another one with hep of renedered

<h:selectOneMenu id="catagoreyEmail"
value="#{managedEmailRespondent.selectCatagoreyEmail}" valueChangeListener="#{managedEmailRespondent.selectCatagoreyEmailValue}" [color=red]onchange="this.form.submit();"[/color] :D >
<f:selectItems id="selectionCatagoreyEmailBody"
value="#{managedEmailRespondent.selectSelectionCatagoreyEmail}" />
</h:selectOneMenu>
 
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic