I have some tabs on my page and I switch between them via normal outputlinks because the model should not be updated. Sure, I could use CommandLinks with immediate=false. But this bug occurs also in other situations (CommandLink and new view creation).
Michael -----Original Message----- From: Jeff Bischoff [mailto:[EMAIL PROTECTED] Sent: Montag, 23. Oktober 2006 16:56 To: MyFaces Discussion Subject: Re: selectOneMenu looses values with myFacesCore 1.1.4 Why are you using outputLink to navigate between pages within your application? This should normally be a commandLink. Regards, Jeff Bischoff Kenneth L Kurz & Associates, Inc. Michael Heinen wrote: > > I have another serious problem with selectMenus and myFacesCore 1.1.4!!! > Pls. see http://issues.apache.org/jira/browse/MYFACES-1430 > > On page1 is a selectMenu with componentBinding. > The corresponding BackingBean has sessionScope. > On this page1 I click an outputLink to page2. > On page2 I click another outputLink back to page1. > Then the selectMenu on page1 is empty !!!! > This is also not the case with myFacesCore 1.1.3 > The used version of tomahawk is 1.1.3. > This bug makes the whole myFaces core 1.1.4 unuseable to me. > And myFacesCore 1.1.3 was not useable due to other bugs. > > I need very urgently a patch for this critical bug. > So could pls one of the developers have a look at this? > > Here are the code snippets to reproduce it: > page1.jsp: > <html><head></head><body> > <f:view> > <h:form id="myform"> > <h:outputText value="Menu"/> > <h:selectOneMenu id="savedSearchesMenu" > binding="#{BBController.savedSearchesMenu}"/> > > <h:outputText value="<br/><br/>uiItems" escape="false"/> > <h:selectOneMenu id="uiItems" value="empty"> > <f:selectItems value="#{BBController.selectItems}"/> > </h:selectOneMenu> > > <h:outputText value="<br/><br/>" escape="false"/> > <h:outputLink value="/ddTest/faces/page2.jsp"><h:outputText > value="doOutpoutLinkToPage2"/></h:outputLink> > </h:form> > </f:view> > </body></html> > > page2.jsp: > <body> > <f:view> > <h:form id="myform"> > <h:outputLink value="/ddTest/faces/page1.jsp"><h:outputText > value="doOutpoutLinkToPage1"/></h:outputLink> > </h:form> > </f:view> > </body> > > BBController: > package com.test; > import java.io.Serializable; > import javax.faces.application.ViewHandler; > import javax.faces.component.UISelectItem; > import javax.faces.component.UISelectItems; > import javax.faces.component.UISelectOne; > import javax.faces.component.UIViewRoot; > import javax.faces.component.html.HtmlSelectOneMenu; > import javax.faces.context.FacesContext; > import javax.faces.event.ActionEvent; > import javax.faces.model.SelectItem; > > public class BackingBean > implements Serializable > { > > private static final long serialVersionUID = 1L; > private transient UISelectOne savedSearchesMenu; > private SelectItem[] selectItems; > > private String text = "MyText"; > > public BackingBean(){ > } > > public UISelectOne getSavedSearchesMenu() > { > System.out.println("getSavedSearchesMenu called"); > if (this.savedSearchesMenu == null) > { > this.populateSavedSearchesMenu(); > } > return this.savedSearchesMenu; > } > > public void setSavedSearchesMenu(UISelectOne savedSearchesMenu) > { > System.out.println("*** setSavedSearchesMenu called"); > this.savedSearchesMenu = savedSearchesMenu; > } > > public SelectItem[] getSelectItems() > { > System.out.println("*** getSelectItems called"); > return this.selectItems; > } > > public void setSelectItems(SelectItem[] l) > { > System.out.println("*** setSelectItems called"); > this.selectItems = l; > } > > private SelectItem[] populateSavedSearchesMenu() > { > this.selectItems = new SelectItem[5]; > > for (int i = 0; i < 5; i++) > { > this.selectItems[i] = new SelectItem(i + " testItem"); > } > > // create new UIcomponents > this.savedSearchesMenu = new HtmlSelectOneMenu(); > > // add an emtpy Select Item > UISelectItem uiItem = new UISelectItem(); > uiItem.setValue(new SelectItem("")); > this.savedSearchesMenu.getChildren().add(0, uiItem); > > // add the saved searches > UISelectItems uiItems = new UISelectItems(); > uiItems.setValue(selectItems); > this.savedSearchesMenu.getChildren().add(uiItems); > > return selectItems; > } > > public String getText() > { > return this.text; > } > } > > FacesConfig: > <faces-config> > <managed-bean> > <managed-bean-name>BBController</managed-bean-name> > > <managed-bean-class>com.test.BackingBean</managed-bean-class> > <managed-bean-scope>session</managed-bean-scope> > </managed-bean> > </faces-config> > > > Michael > > -----Original Message----- > From: Michael Heinen [mailto:[EMAIL PROTECTED] > Sent: Freitag, 29. September 2006 15:16 > To: MyFaces Discussion > Subject: RE: selectOneMenu looses values with myFacesCore 1.1.4 > > The obvious (for me) difference to MyFacesCore 1.1.3 is that > point4 (setSavedSearchesMenu) is not called in 1.1.3. > > But I am not able to debug this further. > > Michael > > -----Original Message----- > From: Michael Heinen [mailto:[EMAIL PROTECTED] > Sent: Freitag, 29. September 2006 11:46 > To: MyFaces Discussion > Subject: RE: selectOneMenu looses values with myFacesCore 1.1.4 > > > Summing up what happenend after clicking the immediate button: > > 1) setSavedSearchesMenu is called > public void setSavedSearchesMenu(UISelectOne savedSearchesMenu) { > this.savedSearchesMenu = savedSearchesMenu; > } > 2) ActionListener is executed and refresh called at the end > private void refresh() { > FacesContext context = FacesContext.getCurrentInstance(); > ViewHandler viewHandler = context.getApplication().getViewHandler(); > UIViewRoot viewRoot = viewHandler.createView(context, > context.getViewRoot().getViewId()); > context.setViewRoot(viewRoot); > context.renderResponse(); > } > > 3) getSavedSearchesMenu is called: > public UISelectOne getSavedSearchesMenu() { > if (this.savedSearchesMenu==null){ > this.populateSavedSearchesMenu(); > } > return this.savedSearchesMenu; > } > > this.savedSearchesMenu is != null and the children are still there. > > 4) setSavedSearchesMenu is called again. > The parameter savedSearchesMenu is not null, but all attributes of it > are null. There are no children anymore!!! All UISelectItems are lost!!! > > Any ideas Martin or anybody else? > Michael > > -----Original Message----- > From: Martin Marinschek [mailto:[EMAIL PROTECTED] > Sent: Freitag, 29. September 2006 09:36 > To: MyFaces Discussion > Subject: Re: selectOneMenu looses values with myFacesCore 1.1.4 > > No, it didn't - must be unrelated. > > regards, > > Martin > > On 9/28/06, Grant Smith <[EMAIL PROTECTED]> wrote: >> I'm not sure if this is related, but see my comment on the commit > r449566, >> which definitely breaks UISelect* components for me. Although that > didn't >> make it into 1.1.4, did it ? >> >> >> >> On 9/28/06, Martin Marinschek <[EMAIL PROTECTED]> wrote: >>> Hi Michael, >>> >>> if you create a new View-Root, it is expected that the old > components >>> get lost - I would say that the selectItems should be recreated. Is >>> that the case in your backing bean? Can you try to clean out the >>> binding as well, and see what happens then? >>> >>> regards, >>> >>> Martin >>> >>> On 9/28/06, Michael Heinen <[EMAIL PROTECTED]> wrote: >>>> >>>> >>>> >>>> Hi, >>>> >>>> >>>> >>>> could anybody of the developers please respond to this issue? >>>> >>>> I would like to update to 1.1.4 but the below issue is of course a > show >>>> stopper. >>>> >>>> >>>> >>>> This code works with 1.1.3 so there must be something working > different >> in >>>> 1.1.4. >>>> >>>> >>>> >>>> Michael >>>> >>>> >>>> >>>> >>>> >>>> ________________________________ >>>> >>>> >>>> From: Michael Heinen [mailto:[EMAIL PROTECTED] >>>> Sent: Mittwoch, 27. September 2006 14:51 >>>> >>>> To: MyFaces Discussion >>>> Subject: RE: selectOneMenu looses values with myFacesCore 1.1.4 >>>> >>>> >>>> >>>> >>>> Sorry for posting answers to my own question but could further > isolate >> the >>>> problem. >>>> >>>> The action listeners that are called by the immediate links, > contain the >>>> following code in order to create new views: >>>> >>>> >>>> >>>> FacesContext context = FacesContext.getCurrentInstance(); >>>> >>>> ViewHandler viewHandler = > context.getApplication().getViewHandler(); >>>> UIViewRoot viewRoot = viewHandler.createView(context, >>>> context.getViewRoot().getViewId()); >>>> >>>> context.setViewRoot(viewRoot); >>>> >>>> context.renderResponse(); >>>> >>>> >>>> >>>> When I remove these lines then the dropdpwn contains all the > expected >>>> values. >>>> >>>> But I have to create a new view in the action listener. >>>> >>>> >>>> >>>> So what's going wrong inside ??? >>>> >>>> >>>> >>>> Michael >>>> >>>> >>>> >>>> >>>> >>>> ________________________________ >>>> >>>> >>>> From: Michael Heinen [mailto:[EMAIL PROTECTED] ] >>>> Sent: Mittwoch, 27. September 2006 14:34 >>>> To: MyFaces Discussion >>>> Subject: RE: selectOneMenu looses values with myFacesCore 1.1.4 >>>> >>>> >>>> >>>> I forgot to mention that SearchControllerBean has sessionScope. >>>> >>>> >>>> >>>> During debugging I found out that the corresponding setter >>>> setSavedSearchesMenu is called two times. >>>> >>>> >>>> >>>> public void setSavedSearchesMenu(UISelectOne >>>> savedSearchesMenu) { >>>> >>>> this.savedSearchesMenu = savedSearchesMenu; >>>> >>>> } >>>> >>>> >>>> >>>> The first time the parameter savedSearchesMenu is correctly > populated. >>>> Then getSavedSearchesMenu is called. >>>> >>>> The setter is called again then and savedSearchesMenu (of type >>>> HtmlSelectOneMenu) is not initialized anymore. >>>> >>>> All attributes are null or false except _valid which is true. >>>> >>>> Any ideas? >>>> >>>> >>>> >>>> Is this a bug (It did work with 1.1.3) ? >>>> >>>> >>>> >>>> Michael >>>> >>>> ________________________________ >>>> >>>> >>>> From: Michael Heinen [mailto: [EMAIL PROTECTED] >>>> Sent: Mittwoch, 27. September 2006 14:07 >>>> To: MyFaces Discussion >>>> Subject: selectOneMenu looses values with myFacesCore 1.1.4 >>>> >>>> >>>> >>>> After updating myFacesCore to 1.1.4 a selectOneMenu is not working >> anymore. >>>> I use tomahawk-1.1.3. >>>> >>>> The entries of the select one menu are cleared after clicking an >> immediate >>>> link. >>>> >>>> When I go back to myFacesCore 1.1.3 everything works fine. >>>> >>>> >>>> >>>> Here is the jsp snippet: >>>> >>>> <h:panelGroup> >>>> >>>> <h:outputText value="Quick Search"/> >>>> >>>> <t:selectOneMenu id="lastSearch" >>>> binding="#{SearchControllerBean.savedSearchesMenu}"/> >>>> >>>> </h:panelGroup> >>>> >>>> >>>> >>>> SearchControllerBean: >>>> >>>> public UISelectOne getSavedSearchesMenu() { >>>> >>>> if (this.savedSearchesMenu==null){ >>>> >>>> this.populateSavedSearchesMenu(); >>>> >>>> } >>>> >>>> return this.savedSearchesMenu; >>>> >>>> } >>>> >>>> >>>> >>>> I set a breakpoint into the above method. >>>> >>>> savedSearchesMenu is a HtmlSelectOneMenu and it's childrenList > contains >> two >>>> objects: >>>> >>>> An UISelectItem and an UISelectItems with 5 SelectItems. >>>> >>>> But these are not displayed anymore in the html. The dropdown is > empty. >>>> Any ideas? >>> >>> -- >>> >>> http://www.irian.at >>> >>> Your JSF powerhouse - >>> JSF Consulting, Development and >>> Courses in English and German >>> >>> Professional Support for Apache MyFaces >>> >> >> >> -- >> Grant Smith >> > >

