• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

A Problem with events

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, first of all, sorry for my poor english

My problem is:
Have a page jsf with 2 SelectOneMenu and 1 commandButton like this
<h:selectOneMenu binding="#{nuevoExpediente.cbObra}" valueChangeListener="# {bean.cbObra_OnChange}" onchange="submit()" >
<f:selectItem itemLabel="Nuevo" itemValue="-1" itemDescription="Introducir nuevo poseedor" />
<f:selectItems binding="#{bean.listobras}" />
</h:selectOneMenu>

<h:selectOneMenu binding="#{bean.cbCliente}" valueChangeListener="# {bean.cbCliente_OnChange}" onchange="submit()" >
<f:selectItem itemLabel="Nuevo" itemValue="-1" itemDescription="Introducir nuevo poseedor" />
<f:selectItems binding="#{bean.listclientes}" />
</h:selectOneMenu>

<h:commandButton id="cmdInsertar" value="Aceptar" action="#{bean.cmdInsertar_OnClick}" />

Cool, now, when the pages FIRST time that i select one item on selectonemenu or click button, page fires ALL events. I think this it because when initialize SelectOneMenu with value="#....", an one event onChange wait on a queue and when any object of form make submit() all event on a queue are throws.
this is:
1� time when page load
- click on a button
- cbObra_OnChange fire ( on queue for give values? )
- cbCliente_OnChange fire ( on queue for give values? )
- cmbInsertar_OnClick fire ( yes, im clicked )


how i can do this? i want that when click on the button first time, only event of button fires.

thanks for all
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Crossposted at Sun forum: http://forums.sun.com/thread.jspa?messageID=10432472#10432472

Please be forthright when crossposting: http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites
[ September 21, 2008: Message edited by: Bauke Scholtz ]
 
tazkirah laskdjf
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try to create a project with this config and try
because the selectonemenu allready have a items on JSF tag, and when load items, modify initials and fires
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I already answered this over there at sun.com. The valueChangeListener will be invoked if the new value differs from the old value.
 
tazkirah laskdjf
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok men, i read all your posts but, try on a new project, because not work...
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't matter if you use a new or old project.

All what matters is that the valueChangeListener will be invoked if the new value differs from the old value. If you think logically, then you should realize that the solution is to make sure that the h:selectOneMenu value is the same as the default value of the f:selectItems. You can prepare that in the constructor of the backing bean or maybe during the filling of the list behind f:selectItems or so.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic