Changing form components by selectOneMenu - so easy, but doesn't work

Hi,
I have silly problem that makes me crazy: I have a little form and I want to change content of all components dependent on my choice made in selectOneMenu. But it doesn't work like it's supposed to in logical way. For instance I have a selectOneRadio component in which I want to display a proper radio marked dependent on my choice in selectOneMenu. So I am setting Radio's 'rodzaj' bean property (Integer) in the valueChangeListener (idZmWart) of Select element to the chosen value. Bean is updated, but no effect on the page at all, no matter of Select's choice. Am I completely misunderstanding JSF lifecycle (studied many times) or it's just a very stupid mistake?
Code is below:
code fragment in jsp page:
<f:view>
  <h:form>
     <h:selectOneMenu id="wyborId" value="#{Backingbean.id}"
                   valueChangeListener="#{Backingbean.idZmWart}"
                   onchange="submit()">                                  
         <f:selectItems value="#{Backingbean.listaId}" />              
     </h:selectOneMenu>
    <h:selectOneRadio id="wyborRodzaj" value="#{Backingbean.rodzaj}"
                  valueChangeListener="#{Backingbean.rodzajZmWart}"
                  onchange="submit()">
         <f:selectItems value="#{Backingbean.listaRodzaj}"/> 
    </h:selectOneRadio>                              
   <h:commandButton value="button" action="#{Backingbean.button_action}" />                               
</h:form>
</f:view>Backingbean code:
package com.jsf;
import java.util.ArrayList;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
public class Backingbean {
   public Backingbean() {
   public String button_action()
      setRodzaj(getId());                
      return "success";
   private Integer id = new Integer(1);
   public Integer getId() {
      return id;
   public void setId(Integer id) {
      this.id = id;
   public void idZmWart(ValueChangeEvent ev) {
      if (ev.getNewValue() != null){
         Integer i = (Integer) ev.getNewValue();
         setRodzaj(i);          
   private ArrayList listaId = new ArrayList();
   public ArrayList getListaId() {     
      ArrayList tmpLista = new ArrayList();
      for (int j=1; j<5; j++) {
         Integer i = new Integer(j);           
         SelectItem si = new SelectItem(i, i.toString());           
         tmpLista.add(si);                    
      listaId = tmpLista;
      return listaId;
   public void setListaId(ArrayList listaId) {
      this.listaId = listaId;
   private Integer rodzaj = new Integer(1);
   public Integer getRodzaj() {
      return rodzaj;
   public void setRodzaj(Integer rodzaj) {
      this.rodzaj = rodzaj;
   private SelectItem[] listaRodzaj = {
      new SelectItem(new Integer(1), "przedmiot"), //value, label
      new SelectItem(new Integer(2), "pracownik"),     
      new SelectItem(new Integer(3), "strona"),     
      new SelectItem(new Integer(4), "menu"),     
   public SelectItem[] getListaRodzaj() {
      return listaRodzaj;     
   public void setListaRodzaj(SelectItem[] listaRodzaj) {
      this.listaRodzaj = listaRodzaj;
   public void rodzajZmWart(ValueChangeEvent ev) {
      if (ev.getNewValue() != null) {
         String sRodzaj = ev.getNewValue().toString();        
}And fragment of faces-config.xml - in one of the many shapes I've tried
<managed-bean>
   <managed-bean-name>Backingbean</managed-bean-name>
   <managed-bean-class>com.jsf.Backingbean</managed-bean-class>
   <managed-bean-scope>session</managed-bean-scope>
   <managed-property>listaId</managed-property>
</managed-bean>
<managed-bean>
   <managed-bean-name>listaId</managed-bean-name>
   <managed-bean-class>java.util.ArrayList</managed-bean-class>
   <managed-bean-scope>session</managed-bean-scope>  
</managed-bean>Thanks for any reply. Regards,
savage82

Yeh sorry the points are not linked so you either can do 1 or 2 or 3
With 3)
You would have to bind all the components that get updated by your value changed listeners to your backing bean (using the binding attribute)
And in your value changed listeners you would call the .setValue() on the components whose variable values changed during the value changed code. When your finished you would call the .renderResponse(). The reason this works is that a straight call to .renderResposne() it seems JSF does something funny, it should call the getters() of your variables then use these values and call the .setValue() on your components. But it doesn�t so instead you call the .setValue() yourself. The problem is you have to update every component potentially allot of work
point 2 is an easy solution
from my blog
public void changeMethod(ValueChangeEvent event)
PhaseId phaseId = event.getPhaseId();
String oldValue = (String) event.getOldValue();
String newValue = (String) event.getNewValue();
if (phaseId.equals(PhaseId.ANY_PHASE))
event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
event.queue();
else if (phaseId.equals(PhaseId.UPDATE_MODEL_VALUES))
// do you method here
}what this does the changeMethod will get called twice. First off it gets called when it is meant to during validation phase. So we catch this call in our if statment then we queue the value changed event until the update model phase. So then when the update model phase is called your value changed event will be fired again. Basically this just moves the value changed code after the setters are called. That way any changes you make to your component values in your value change code will not be overwritten by the setters.
point 1)
Sorry forgot to add you may need renderResponse() after navigation rule (should test this)
using the navigation rule well i dont exactly understand why this works. But my educated guess is using a navigation rule forces jsf to recreate the view i.e. the component tree is lost so the values you change in your value changed listeners will be reflected in your components as the components get recreated with the changed variables values.
So take the above code
and replace // do you method here
with whatever your value changed code would be
This is possibly a bad solution not exactly sure the performance hit you would take on this one i have never noticed any problems with my system but never benched marked it either.

Similar Messages

  • HT4314 Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. Then I playing game I

    Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. Then I playing game I can see what someone else trying connecting to my game And I don't know what to do.So if you can help me please? I don't wanna lose my game.

    Contact iTunes
    Contact iTunes

  • Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. Then I playing game I can se

    Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. When I playing game I can see what someone else trying connecting to my game And I don't know what to do.So if you can help me please? I don't wanna lose my game. 

    Hello Vaidas Vaidas,
    It sounds like you are noticing someone else is accessing your Clash of Clans data by playing the game and you have tried to reset your Apple ID password. If you are following the steps outlined in this article:
    Apple ID: Changing your password
    http://support.apple.com/kb/ht5624
    What is preventing you from changing your password? Any error messages or prompts?
    Thank you for using Apple Support Communities.
    All the best,
    Sterling

  • I have a VGA adapter and an iPad2.  Tried projecting my iPad2 to projector using the VGA but doesn't work.  Tried it with friend's iPad1 and it works.  Why??

    I have a VGA adapter and an iPad2.  Tried projecting my iPad2 to projector using the VGA but doesn't work.  Tried it with friend's iPad1 and it works.  Why??  Pls help.

    Yup - nothing happens.  I then took the same VGA cable and plugged it into my friend's iPad1 and it worked perfectly when she opened Keynote.  My understanding is that the iPad2 mirrors the entire screen, so no need to go into any specific application in order to project to the screen, right?  Do I need to download any specific app or change any settings in order to be able to project the screen using VGA?
    Sorry - novice at this.  Not very tech minded either...

  • Bought game for BB, but doesn't work

    I bought a game on Bplay, and have received 2 mails on my computer about the purchasing. So I had to forward the mail to my phone, and open the link that was in the mail, when I open it on my phone it says:
    "Not Available on DesktopNot Available on Desktop
    Please visit this URL with your BlackBerry device. If you are on your device and believe you arrived here in error, please follow the directions below to ensure you are using the correct browser.
    Push the BlackBerry button (or track-wheel for those without a BlackBerry button) to bring up the menu. Select options.
    Select General Properties.
    Make sure your default browser is: Internet Browser
    Exit out of General Properties and enter Browser Configuration.
    Scroll down to Emulation Mode / Browser Identification and make sure it is set to BlackBerry."
    If I change the things and try it again, it doesn't work again. I payed 9.99 dollar for this, that's not a problem at all, but I really want this game.
    Can someone please help me?
    My pin is: 255CD889
    I almost always respond immediatly and otherwise I'm sleeping and reply when I wake up
    Hope someone can help me!
    thanks

    dzero wrote:
    huh so i payed for nothing?
    first i couldnt download it and a day later they say its valid
    it doesnt work, what you told me on bb messenger.
    what can i do?
    again go to https://www.bplay.com/purchases/regen.php   enter your email address you used for purchase you will get a email with a link go to the link in the email and will take you to a page that shows ALL your past purchases... Click on the resend download link for this game and will then email you a new link to download the game click on that link on your Blackberry.

  • Firefox crashing AND the scroll feature on my PC finger pad works with other browsers, but doesn't work on Firefox, which just happened since I updated. FRUSTRATING!

    Since I updated, Firefox is crashing daily. The finger scroll feature on my PC works with other browsers, but doesn't work on Firefox. It is also very, very slow, but other browsers aren't. I can't use it anymore until it's fixed.

    To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
    If you see a warning then you can confirm that you want to access that page.<br />
    *Use the Filter bar at to top of the about:config page to locate a preference more easily.
    *Preferences that have been modified show as bold (user set).
    *Preferences can be reset to the default via the right-click context menu if they are user set
    *Preferences can be changed via the right-click context menu: Modify (String or Integer) or Toggle (Boolean)
    *http://kb.mozillazine.org/about:config

  • The wifi at my school isn't very good. And I can't send iMessages through it. It works for some apps like score center and my radar app, but doesn't work for other apps like clash of clans and iMessage. How can I get it to work on that  wifi network

    The wifi at my school isn't very good. And I can't send iMessages through it. It works for some apps like score center and my radar app, but doesn't work for other apps like clash of clans and iMessage. How can I get it to work on my school wifi. I have an iPhone 4S on AT&T and iOS 7.04

    In a roaming network, your "main" router is the device that would require port mapping/forwarding to be configured in order to access the IP camera from the Internet. This router is also the one that would be provide the private IP address for the camera which you will want to be a static one.
    So as you described your network, the IP cameras should be getting an IP address or you assigned it a static one and this is the address that you would enter in the Private IP address (or equivalent depending on the router used) field when setting up port mapping.
    If you are not able to access this camera from the local network, then this should be troubleshot first.

  • I updated my iphone 5 to ios 6.0.2. my wifi says its connected but doesn't work now. It doesn't matter what wifi network I connect to. It worked before updating my phone. I can no longer use facetime or use wifi at all. I'm not sure what to do to fix it.

    I updated my iphone 5 to ios 6.0.2. my wifi says its connected but doesn't work now. It doesn't matter what wifi network I connect to. It worked before updating my phone. I can no longer use facetime or use wifi at all. I'm not sure what to do to fix it.

    I'm having similar issues with my phone.  I got my first iPhone recently, only had an iPod touch gen4 for a little over a year.  Updated to 6.0.2 when we got the phone (iPhone 5) a few days before Christmas.  When I got home on the evening of January 11, my phone would not connect the router anymore.  I was able to get it to connect after resetting the phone and the router, updating the router, and manually connecting.  That laste for a few minutes and then wouldn't work anymore.   I live in an area with very limited service, we have a network extender installed to help, and I am barely getting a 3G signal at times.
    My wife's iPad 4, my touchiPod 4, and all of our laptops are working just fine on the router.  When I dropped my kid off at school today, I noticed that I am not even seeing the school network anymore from the parking lot where before I got 3 or 4 bars and could connect to their wifi when I was there.  Today my phone goes back and forth between seeing my home network but not connecting, to not even seeing the network at all even from the same room that the router is in.
    Hope Apple fixes this problem soon..............

  • After change to Mavericks my Mac become too slow e I can't use it because stays asking passwords for "talagent" and "messages agent" as icloud keys. I got changed the icloud password many times and still doesn't work. I can't open any program.

    After change to Mavericks my Mac become too slow e I can't use it because stays asking passwords for "talagent" and "messages agent" as icloud keys. I got changed the icloud password many times and still doesn't work. I can't open any program.

    Back up all data.
    Launch the Keychain Access application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Keychain Access in the icon grid.
    Select the login keychain from the list on the left side of the Keychain Access window. If your default keychain has a different name, select that.
    If the lock icon in the top left corner of the window shows that the keychain is locked, click to unlock it. You'll be prompted for the keychain password, which is the same as your login password, unless you've changed it.
    Right-click or control-click the login entry in the list. From the menu that pops up, select Change Settings for Keychain "login". In the sheet that opens, uncheck both boxes, if not already unchecked.
    From the menu bar, select
    Keychain Access ▹ Preferences ▹ First Aid
    If the box marked Keep login keychain unlocked is not checked, check it.
    Select
    Keychain Access ▹ Keychain First Aid
    from the menu bar and repair the keychain. Quit Keychain Access.

  • After I change iPhone 5 to 6 , my message app doesn't work properly.

    After I change iPhone 5 to 6 , my message app doesn't work.
    1. messages history may suddenly disappear ,after i restart phone , it comes back.
    2. sent text from contacts, wont see message history or crash. after send message, all history will come back.
    3. open message app always very slow.
    I nv delete my message since 2010. So there is alot of messages ( estimate 40K messages) in my phone. however, when i was using iphone 5, it works fine. 

    After I change iPhone 5 to 6 , my message app doesn't work.
    1. messages history may suddenly disappear ,after i restart phone , it comes back.
    2. sent text from contacts, wont see message history or crash. after send message, all history will come back.
    3. open message app always very slow.
    I nv delete my message since 2010. So there is alot of messages ( estimate 40K messages) in my phone. however, when i was using iphone 5, it works fine. 

  • After i update the 10.10.2 OS X Yosemite my iPhoto stops working. In the warning that appears when I try to open the app says that happened a mistake because of this update. I reinstalled the app but doesn't work anyway. Please, HELP!

    after i update the 10.10.2 OS X Yosemite my iPhoto stops working. In the warning that appears when I try to open the app says that happened a mistake because of this update. I reinstalled the app but doesn't work anyway. Please, HELP!

    I already tried that but it doesn't work. Appears a warning saying: "See the developer to make sure that iPhoto works with this version of OS X. You may need to reinstall the application. Be sure to install all available updates in the application and OS X."

  • I accidently turned voice over on,I've tried triple clicking the home button to bring up voice over options but doesn't work. I can't scroll down to get to Accesibility in genereal even with three fingers.

    I accidently turned voice over on,I've tried triple clicking the home button to bring up voice over options but doesn't work. I can't scroll down to get to Accesibility in genereal even with three fingers.

    This article can show you how to disable it through iTunes on a PC/Mac:
    iOS: Configuring accessibility features

  • I was wondering if there's a way to connect to my work server from my home iMac i7. I can't seem to get Share Screen to work. I have tried connecting to server using the vnc but doesn't work.

    I was wondering if there's a way to connect to my work server from my home iMac i7. I can't seem to get Share Screen to work. I have tried connecting to server using the vnc but doesn't work.

    The easiest way would be to use Back to My Mac, but that will only work if the server is a Mac running OS X 10.7 or later and you have the cooperation of the network administrator.
    OS X: Using and troubleshooting Back to My Mac with your iCloud account

  • I have internet optic fiber connection and I'm trying to configure it with my Airport Express but doesn't works, appears that I have IP and DNS, as I'm a computers dummy , who could help me to configuration it, please?

    I have internet optic fiber connection and I'm trying to configure it with my Airport Express but doesn't works, appears that I have IP and DNS, as I'm a computers dummy , who could help me to configuration it, please?

    You're welcome.
    Voicemail is left at your carrier's server. That will continue to work unless you report your iPhone as lost or stolen with your carrier.
    You may never find it again and you can't if the iPhone remains offline or out of service which means the iPhone is powered off or doesn't have cellular reception.

  • HT204051 I'm unable to connect my iphone 5s to the Dlink router. I tried all the apple support suggestions. But doesn't work. Please let me know.

    I'm unable to connect my iphone 5s to the Dlink router. I tried all the apple support suggestions. But doesn't work. Please let me know.

    I'm having this problem now with my 2 weeks old iPhone 6+. in the beginning everything going great and managed to connect every wifi around me. Then suddenly 1 week ago, All the wifi from my office, home, hotel and coffee house saying either incorrect password or can't join the wifi. But when i switch on my hotspot from my iPhone 5 it can be connect. i also try with my friend iPhone hotspot. So is it because of hardware problem or software problem. And i just restore my iPhone6+ and still can't connect to wifi and manage to join hotspot (also wifi right?) regret as all my downloaded stuff vanish and now can't download back using wifi.....
    Thanks for assisting

Maybe you are looking for

  • Who else does not have cut and paste, or shift click anymore on Lion?

    I can't cut and paste anything, and shift click doesn't work like it normally should. Shift click is acting like command shift insead of selecting everything between. Please, no ******** answers.

  • I no longer can send iMessages from my iPhone (iOS 6.0.1) to one of my contacts.

    Started about a week ago.  I can send them from my Mac, but not my phone.  Other iPhone users are receiving iMessages from me. Just not this one person.  I also note that in my contact info for her on my phone, I cannot select iPhone as her mobile de

  • How Long Does Bootcamp asst take to install??? necessary?

    i just got a mac book pro 2011 i am new to it and trying to merge my PC with it. i installed the latest Lion, purchased parallels desktop 7 for Mac, installed that, then Windows 7. during bootcamp dowload stays froze in the middle.  i dont know if i

  • Opatch apply is failing

    Hello All, I am trying to apply patches my system is tru-64. same patches worked in another system. Now when i am saying "opatch apply" i am getting error "/usr/ccs/bin/ar: Error: cannot create temp file" does anybody is having any idea ? regrads, Aj

  • Firefox is not saving the password for my spam website.

    This all started when I was browsing through my options and looked at my Saved Passwords. There were two entries for my spam e-mail website. I deleted one of them. Later, when I had to view spam, Firefox no longer remember my password. When I checked