SelectOneMenu and ValueChangeListener

Hi All,
I am a new user of JSF components. I've got a problem about getting the selected value from the selectedOneMenu component. I have 3 selectOneMenu box and each has valueChangeListener.
I wanna get first selected id and get the second value according to the first selected id and so on.
The frist value change listener submit and get the selected value.But when the second value change listener submit the value, the first selectOneMenu also submit the value, so the previous value is lost and return null cause of no selection in the first box.
I 've separate these component to three separate forms . But when one of the ValueChangeListener is execute, the others also execute.
So , How can I pass this problem..
Here is my coding...
<h:form id="form1">
                    <h:panelGrid columns="3">
                    <h:column><h:outputLabel value="Category L1 : " /> </h:column>
               <h:column>
                         <h:selectOneMenu id="selectValue"
                                                  onchange="this.form.submit();"
                                             immediate="true"
                                             value="#{categoryBean.selectValue}"
                                             valueChangeListener="#{categoryBean.item1Change}">
                                   <f:selectItems value="#{categoryBean.menuItem1}"/>
                         </h:selectOneMenu>
                    </h:column>     
                    <h:column></h:column>               
                    <h:column><h:outputLabel value="Description : " /></h:column>
                    <h:column><h:outputText value="test" /></h:column>
                    <h:column><h:commandButton action="" value="Add New" /></h:column>
                    </h:panelGrid>
                    <h:inputHidden value="#{categoryBean.tempValue}" />
               </h:form>
               <h:form id="form2">
                    <h:panelGrid columns="3">
                    <h:column><h:outputLabel value="Category L2 : " /> </h:column>
               <h:column>
                         <h:selectOneMenu id="selectValue2"
                                                  onchange="this.form.submit();"
                                                  immediate="true"
                                                  value="#{categoryBean.selectValue2}"
                                                  valueChangeListener="#{categoryBean.item2Change}">
                                   <f:selectItems value="#{categoryBean.menuItem2}"/>
                         </h:selectOneMenu>
                    </h:column>     
                    <h:column></h:column>               
                    <h:column><h:outputLabel value="Description : " /></h:column>
                    <h:column><h:outputText value="test" /></h:column>
                    <h:column><h:commandButton action="" value="Add New" /></h:column>     
                    </h:panelGrid>
               </h:form>     
               <h:form id="form3">
                    <h:panelGrid columns="3">
                    <h:column><h:outputLabel value="Category L3 : " /> </h:column>
               <h:column>
                         <h:selectOneMenu id="selectValue3"
                                                  onchange="this.form.submit();"
                                             immediate="true"
                                                  value="#{categoryBean.selectValue3}"
                                                  valueChangeListener="#{categoryBean.item3Change}">
                                   <f:selectItems value="#{categoryBean.menuItem3}"/>
                         </h:selectOneMenu>
                    </h:column>     
                    <h:column></h:column>               
                    <h:column><h:outputLabel value="Description : " /></h:column>
                    <h:column><h:outputText value="test" /></h:column>
                    <h:column><h:commandButton action="" value="Add New" /></h:column>
                    </h:panelGrid>     
               </h:form>          
     public void item1Change(ValueChangeEvent event) {
          Utils.log(getFacesContext(),"Win b kwa...1.........");
          PhaseId phaseId = event.getPhaseId();
          String oldValue = (String) event.getOldValue();
          String newValue = (String) event.getNewValue();
          this.tempValue = newValue;
          if (phaseId.equals(PhaseId.ANY_PHASE))
               event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
               event.queue();
          else if (phaseId.equals(PhaseId.UPDATE_MODEL_VALUES))
          Utils.log(getFacesContext(),"New Value is......"+newValue );
          if(newValue == null){
               logger.info("Next time win tar.....");
          else{
               this.setSelectValue(newValue);
          Utils.log(getFacesContext(), "In L1 : Selected Value is..."+this.getSelectValue());
          this.menuItem2 = this.getCategoryList(this.getSelectValue());
          FacesContext context = FacesContext.getCurrentInstance();
          context.renderResponse();
please help me.. thanks in advance...

There's a few things...
First, and foremost, is that you have two forms on the page. This is a bad idea with JSF. It tends to mess things up (although, some people may have gotten it to work right). You might want to find a way to have only one h:form tag per page. That shouldn't actually be too hard.
Next, it looks like you set up your selectOneMenu tags properly. You have the valueChangeListener, immediate=true and a form submit onchange. Good!
However, the valueChangeListener implementation is different than what I usually see. You're queueing up the event to fire in UPDATE_MODELS phase... This is strange. This will probably undo the fact that you put immediate="true" on your component in the first place.
My suggestion is not to manipulate the phases this way, for your particular problem. Instead, get the new value and set the selected value (without retrieving the phaseId). Then call facesContext.renderResponse() at the end of your valueChangeListener implementation. Something like this:
public void item1Change(ValueChangeEvent event) {
    String newValue = (String) event.getNewValue();
    if(newValue == null){
        logger.info("Next time win tar.....");
    else{
         this.setSelectValue(newValue);
    Utils.log(getFacesContext(), "In L1 : Selected Value is..."+this.getSelectValue());
    //What's this?
    this.menuItem2 = this.getCategoryList(this.getSelectValue());
    FacesContext context = FacesContext.getCurrentInstance();
    context.renderResponse();
}Start there. There may be a few more problems.
CowKing

Similar Messages

  • The scenario is:  I have a page consisting of SelectOneMenu and different t

    The scenario is:
    I have a page consisting of SelectOneMenu and different text fields. Based on the values selected from the select one menu,
    some of the text fields need to be made mandatory.
    Using onchange = "submit()" will validate other fields also, which I do not want to do at this time.
    Hence I have used code as shown below which invokes a command button(that has immediate=true so that validation will
    not be performed for other fields) when values are changed . In the value changed event method , I set the rendered property
    of the mandatory text field.
    <h:selectOneMenu id="source" value="#{companyPaymentRemark.prVO.sourceID}" 
        onchange="buttonClick('layout:content:hiddenSubmit')" valueChangeListener="#{companyPaymentRemark.sourceValueChange}"> 
                <f:selectItems value="#{companyPaymentRemark.sourceList}" /> 
         </h:selectOneMenu> 
        <h:commandButton id="hiddenSubmit" immediate="true" action="" style="display:none"/> 
    <h:selectOneMenu id="source" value="#{companyPaymentRemark.prVO.sourceID}" onchange="buttonClick('layout:content:hiddenSubmit')" valueChangeListener="#{companyPaymentRemark.sourceValueChange}"> <f:selectItems value="#{companyPaymentRemark.sourceList}" /> </h:selectOneMenu> <h:commandButton id="hiddenSubmit" immediate="true" action="" style="display:none"/>The problem is that the value changed listener is never getting invoked
    My thinking is that using immediate=true will only skip Convertion ,Validation and update model phase and the listener should be called as is.
    Regards,
    Joshua

    This article may be helpful then: [http://balusc.blogspot.com/2007/10/populate-child-menus.html].

  • Question regarding selectOneMenu and PROCESS_VALIDATIONS(3) phase

    Hi im a bit lost regarding selectOneMenu and how validation phase all works together.
    The thing is that i have a simple selectOneMenu
    <h:form id="SearchForm">                                                  
         <h:panelGrid columns="3"  border="0">
              <h:outputLabel id="caseTypeText" value="#{msg.searchCaseCaseType}" for="caseType" />                         
              <h:selectOneMenu id="caseType" value="#{searchCaseBean.caseType}" style="width: 200px;" binding="#{searchCaseBean.caseTypeSelect}">     
                   <f:selectItem itemValue="" itemLabel="#{msg.CommonTextAll}" />                                             
                   <f:selectItems value="#{searchCaseBean.caseTypes}"  />                              
              </h:selectOneMenu>
              <h:message for="caseType" styleClass="errorMessage" />
              <h:panelGroup />
              <h:panelGroup />
              <h:commandButton action="#{searchCaseBean.actionSearch}" value="#{msg.buttonSearch}" />
         </h:panelGrid>
    </h:form>Now when i hit submit button i can see that the bean method searchCaseBean.caseTypes (used in the <f:selectItems> tag) is executed in the PROCESS_VALIDATIONS(3) phase. How come? I dont whant this method to be executed in phase 3, only in phase 6.
    If i add the this in the method if (FacesContext.getCurrentInstance().getRenderResponse())
    public List<SelectItem> getStepStatuses(){
         List<CaseStep> caseSteps = new ArrayList<CaseStep>();
         if (FacesContext.getCurrentInstance().getRenderResponse()) {
              caseSteps = getCaseService().getCaseStep(value);     
         List<SelectItem> selectItems = new ArrayList<SelectItem>(caseSteps.size());
         for(int i=0; i < caseSteps.size(); i++){
              CaseStep step = caseSteps.get(i);               
              String stepStatus = step.getStatus() + "_" + step.getSubStatus();           
              selectItems.add(new SelectItem(stepStatus, step.getShortName()));
         return selectItems;
    } Now i get a validation error (javax.faces.component.UISelectOne.INVALID) for the select field and only phase1, phase2, phase 3 and phase 6 is executed.
    Im lost?

    I see. Many thanxs BalusC. Im using your blog very often, and its very helpfull for me.
    I changed now to use the constructor load method instead. But know im getting problem of calling my service layer (Spring service bean). Its seems they havent been init when jsf bean is calling its constructor.
    Can i init the spring service bean from the faces-config file?
    JSF Bean
        public SearchCaseBean() {
              super();
                    //caseService need to be init
              if(getCaseService() == null){
                   setCaseService((CaseService)getWebApplicationContextBean("caseService"));
              fillCaseTypeSelectItems();
              fillCaseStatusSelectItems();
    .....faces-config
    <managed-bean>
              <managed-bean-name>searchCaseBean</managed-bean-name>
              <managed-bean-class>portal.web.SearchCaseBean</managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>          
              <managed-property>
                   <property-name>caseService</property-name>
                   <value>#{caseService}</value>
              </managed-property>
         </managed-bean>

  • H:selectOneMenu and converter problem

    Hello
    I'm working on an application (Address Database) using JSF (Base JSF libs with IBM Faces). Apache Tomcat Server 5.5.
    Since days i'm trying to solve my problem with h:selectOneMenu and converter. I can save values correctly, but i cannot display the saved value again as a selected item.
    so here is my jsf code section:
         <h:selectOneMenu value="#{personBean.person.representative}"
                        styleClass="fldDefault fldcombo">
                        <f:selectItems value="#{partnerBean.representatives}" />
                        <f:converter converterId="keywordConvertor" />
                        <f:attribute name="SelectItemArrayList"
                             value="#{partnerBean.representatives}" />
         </h:selectOneMenu>
    representatives are keywords and in the selectOneMenu, a representative keyword object is stored.
    here is my partnerBean.jsp Code:
         private List<SelectItem> representatives = null;
         * populate keywords of type REPRESENTATIVE
         public void populateRepresentatives() {
              representatives = new ArrayList<SelectItem>();
              ArrayList<Keyword> representativeKeywords = kwHandler
                        .getKeywordsByType(KW_REPRESENTATIVE_TYPE);
              for (Keyword keyword : representativeKeywords) {
                   representatives.add(new SelectItem(keyword, keyword
                             .getKwDescription()));
    so the function gets the representative keyword objects, loop through them and add a newly created SelectItem Object to the representatives list.
    There is a converter in order to save and display (should!!) the values:
    public class KeywordConvertor implements Converter {
         public Object getAsObject(FacesContext context, UIComponent component,
                   String value) {
    ....code for saving...
         public String getAsString(FacesContext context, UIComponent component,
                   Object obj) {
    `          System.out.println(((Keyword) obj).getId()+"");
              return ((Keyword) obj).getId()+"";
    i did not provide the code for getAsObject, since the saving of the combo box works fine. If it has to do something with my problem, please ask me for this code..
    The System.out.prinln prints all ids correctly, but the generated HTML Code does not select the given value in the combobox.
    So whats wrong with the getAsString Method? or is the function completely somewhere else?
    I have to say that the function ((Keyword) obj).getId() returns a long !! is that the problem?
    Any help is very appreciated

    Hello
    i implemented the function in the Keyword Class:
    public class Keyword implements Serializable {
         public boolean equals(Keyword kw) {
              System.out.println("calling equals in:" + kw.getId());
              if (kw.getId() == this.getId()) {
                   return true;
              } else {
                   return false;
    but the System.out.print is not executed...
    i tried also:
         public boolean equals(Object o) {
              Keyword kw = (Keyword) o;
              System.out.println("calling equals in:" + kw.getId());
              if (kw.getId() == this.getId()) {
                   return true;
              } else {
                   return false;
    but then i get the following error message:
    org.apache.jasper.JasperException: javax.servlet.jsp.JspException: could not initialize proxy - no Session
    hmmm, could you show me how to implement the equals Function correctly?

  • Browser compatibility problem with t:selectOneMenu and JavaScript calendar

    I'm having problem with <t:selectOneMenu> and JavaScript calendar on IE. It works fine on Firefox but doesn't work on IE.
    The JSF code is as follows:
    <tr>
                                       <td align="right">
                                            Archive Date
                                       </td>
                                       <td align="left" colspan="3">
                                       <table cellpadding="0" cellspacing="0" border="0">
                                       <tr>
                                       <td>
                                       <span class="tuny_text">After&#160;(Ex. Oct 18, 2007)</span>
                                            <h:outputLabel for="txtArchiveDateAfter" value="Archive Date After" rendered="false"/>
                                            <br/>
                                            <t:inputText required="false" value="#{nonItemImageSearchPage.stringArchiveDateAfter}" name="txtArchiveDateAfter" id="txtArchiveDateAfter" forceId="true"  styleClass="inp" style="width: 128px">
                                       </t:inputText>
                                            <t:graphicImage value="/images/calendar.png" id="dtpArchiveDateAfter" name="dtpArchiveDateAfter" forceId="true" style="border: 2px solid #EEE; cursor: pointer"></t:graphicImage>
                                            <br/>
                                            <t:message for="txtArchiveDateAfter" styleClass="form_error" replaceIdWithLabel="true"></t:message>
                                       </td>
                                       <td>
                                       <span class="tuny_text">Before&#160;(Ex. Oct 18, 2007)</span>
                                            <h:outputLabel for="txtArchiveDateBefore" value="Archive Date Before" rendered="false"/>
                                            <br/>
                                            <t:inputText value="#{nonItemImageSearchPage.stringArchiveDateBefore}" name="txtArchiveDateBefore" id="txtArchiveDateBefore" forceId="true" style="width:128px" styleClass="inp">
                                       </t:inputText>
                                            <t:graphicImage value="/images/calendar.png" id="dtpArchiveDateBefore" name="dtpArchiveDateBefore" forceId="true" style="border: 2px solid #EEE; cursor: pointer"></t:graphicImage>
                                            <br/>
                                            <t:message for="txtArchiveDateBefore" styleClass="form_error" replaceIdWithLabel="true"></t:message>
                                       </td>
                                       </tr>
                                       </table>
                                       </td>
                                  </tr>
                                  <tr>
                                       <td align="right" >
                                            <h:outputLabel for="drpBackground" value="Background"/>
                                       </td>
                                       <td align="left" class="right_separator">
                                            <t:selectOneMenu id="drpBackground" forceId="true" value="#{nonItemImageSearchPage.nonItemImageSearchModel.backgroundId}" styleClass="inp" style="width: 150px">
                                            <f:selectItem itemLabel="--------" itemValue="-1"/>
                                            <s:selectItems value="#{nonItemImageSearchPage.backgroundPrefsList}"
                                                      var="backgroundPrefs" itemValue="#{backgroundPrefs.id}" itemLabel="#{backgroundPrefs.description}" />
                                            </t:selectOneMenu>
                                       </td>
                                       <td  align="right" class="left_separator">
                                            <h:outputLabel for="drpTheme" value="Theme"/>
                                       </td>
                                       <td align="left" >
                                            <t:selectOneMenu id="drpTheme" forceId="true" value="#{nonItemImageSearchPage.nonItemImageSearchModel.themeId}" styleClass="inp WCHhider" style="width:150px;">
                                            <f:selectItem itemLabel="--------" itemValue="-1"/>
                                                 <s:selectItems value="#{nonItemImageSearchPage.themePrefsList}"
                                                      var="themePrefs" itemValue="#{themePrefs.id}" itemLabel="#{themePrefs.description}" />
                                            </t:selectOneMenu>
                                       </td>
                                  </tr>
                                  <tr>
                                       <td align="right" >
                                            <h:outputLabel for="drpSeason" value="Season"/>
                                       </td>
                                       <td align="left" class="right_separator">
                                            <t:selectOneMenu id="drpSeason" forceId="true" value="#{nonItemImageSearchPage.nonItemImageSearchModel.seasonId}" styleClass="inp" style="width:150px">
                                            <f:selectItem itemLabel="--------" itemValue="-1"/>
                                                 <s:selectItems value="#{nonItemImageSearchPage.seasonPrefsList}"
                                                      var="seasonPrefs" itemValue="#{seasonPrefs.id}" itemLabel="#{seasonPrefs.description}" />
                                            </t:selectOneMenu>
                                       </td>
                                       <td align="right" class="left_separator">
                                            <h:outputLabel for="drpClothing" value="Clothing"/>
                                       </td>
                                       <td align="left"  >
                                            <t:selectOneMenu id="drpClothing" forceId="true" value="#{nonItemImageSearchPage.nonItemImageSearchModel.clothingId}" styleClass="inp" style="width:150px">
                                            <f:selectItem itemLabel="--------" itemValue="-1"/>
                                                 <s:selectItems value="#{nonItemImageSearchPage.clothingPrefsList}"
                                                      var="clothingPrefs" itemValue="#{clothingPrefs.id}" itemLabel="#{clothingPrefs.description}" />
                                            </t:selectOneMenu>
                                       </td>
                                  </tr>
                                  <tr>
                                       <td align="right" >
                                            <h:outputLabel for="drpToy" value="Toy"/>
                                       </td>
                                       <td align="left" class="right_separator">
                                            <t:selectOneMenu id="drpToy" forceId="true" value="#{nonItemImageSearchPage.nonItemImageSearchModel.toyId}" styleClass="inp" style="width:150px">
                                            <f:selectItem itemLabel="--------" itemValue="-1"/>
                                                 <s:selectItems value="#{nonItemImageSearchPage.toyPrefsList}"
                                                      var="toyPrefs" itemValue="#{toyPrefs.id}" itemLabel="#{toyPrefs.description}" />
                                            </t:selectOneMenu>
                                       </td>
                                       <td align="right" class="left_separator">
                                            <h:outputLabel for="drpJuvenile" value="Juvenile"/>
                                       </td>
                                       <td align="left" >
                                            <t:selectOneMenu id="drpJuvenile" forceId="true" value="#{nonItemImageSearchPage.nonItemImageSearchModel.juvenileId}" styleClass="inp" style="width:150px">
                                            <f:selectItem itemLabel="--------" itemValue="-1"/>
                                                 <s:selectItems value="#{nonItemImageSearchPage.juvenilePrefsList}"
                                                      var="juvenilePrefs" itemValue="#{juvenilePrefs.id}" itemLabel="#{juvenilePrefs.description}" />
                                            </t:selectOneMenu>
                                       </td>
                                  </tr>
                                  <tr>
                                       <td align="right">
                                            <h:outputLabel for="drpGroup" value="Grouping"/>
                                       </td>
                                       <td align="left"  class="right_separator">
                                            <t:selectOneMenu id="drpGroup" forceId="true" value="#{nonItemImageSearchPage.nonItemImageSearchModel.modelGroupingId}" styleClass="inp" style="width:150px;">
                                            <f:selectItem itemLabel="--------" itemValue="-1"/>
                                                 <s:selectItems value="#{nonItemImageSearchPage.groupPrefsList}"
                                                      var="groupPrefs" itemValue="#{groupPrefs.id}" itemLabel="#{groupPrefs.description}" />
                                            </t:selectOneMenu>
                                       </td>
                                       <td class="left_separator">&#160;</td>
                                       <td>&#160;</td>
                                  </tr>
    The JavaScript code is as follows:
    <script type="text/javascript" language="javascript">
         var dtpArchiveDateBefore = new MooCal("txtArchiveDateBefore");
         var dtpArchiveDateAfter = new MooCal("txtArchiveDateAfter");
         window.addEvent("domready", function(){
           $("dtpArchiveDateBefore").addEvent("click", function(e){
                    var event = new Event(e).stop();
                      var x = (event.client.x)-150;
                      var y = event.client.y;
                      dtpArchiveDateBefore.show(x,y);  // Display the calendar at the position of the mouse cursor
                      dtpArchiveDateBefore.minYear = 1800;
                        dtpArchiveDateBefore.maxYear = 2017;
         /*$("txtArchiveDateBefore").addEvent("click", function(e){
                 e.target.blur();
                    var event = new Event(e).stop();
                      var x = (event.client.x)-150;
                      var y = event.client.y;
                      dtpArchiveDateBefore.show(x,y);  // Display the calendar at the position of the mouse cursor
                      dtpArchiveDateBefore.minYear = 1800;
                        dtpArchiveDateBefore.maxYear = 2017;
        $("dtpArchiveDateAfter").addEvent("click", function(e){
                    var event = new Event(e).stop();
                      var x = (event.client.x)-150;
                      var y = event.client.y;
                      dtpArchiveDateAfter.show(x,y);  // Display the calendar at the position of the mouse cursor
                      dtpArchiveDateAfter.minYear = 1800;
                        dtpArchiveDateAfter.maxYear = 2017;
       /* $("txtArchiveDateAfter").addEvent("click", function(e){
                 e.target.blur();
                    var event = new Event(e).stop();
                      var x = (event.client.x)-150;
                      var y = event.client.y;
                      dtpArchiveDateAfter.show(x,y);  // Display the calendar at the position of the mouse cursor
                      dtpArchiveDateAfter.minYear = 1800;
                        dtpArchiveDateAfter.maxYear = 2017;
         </script>When the calendar is above t:selectOneMenu, it doesn't show up on t:selectOneMenu area. Could anyone help me solve the issue?
    Thanks
    Rashed

    There are dozens of CSS attributes that can (and have to) be handwritten. Trouble with them is that, like text shadows, they don't appear in all browsers. I have nine different browsers installed and test pages in ALL of them before I "finish" building site or page for a template.
    I try to build for Firefox, out of personal preference for it, but I have to do things that work with IE because it still holds the market share (46%IE to 42%FF), and I will only go with designs that work in IE, FF, NS, Opera, Safari, and Chrome.
    As to your questions.
    1. The compatibility check is most likely current with the time of the build. I don't know if that component updates as browsers do, but I'd tend to think it doesn't. I'm using CS4  and there haven't been any updates for it in nearly a year. Firefox has released 4.0, Opera released 11, and Safari released 5 since then. The updater would have found and downloaded something if it was available.
    2. I could only guess. Text shadows DON'T show up in design view (or in IE) but they do in browser preview. It's just a UI quirk, and it means "trial and error" is the onyl way to get what you want.
    3. The quick-selects which are in DW dropdowns or popouts are the ones most  common to CSS designs and have been proven to work with all browsers at the time of release of your particular build of DW.
    Hope that helps..

  • Replacement for validator and valueChangeListener attributes in JSF1.2

    Is there a replacement for these now deprecated attributes (in JSF 1.2 according to the proposed final draft). Or is the onlyl solution to use i.e. the f:validate tag and implement the Validator Interface. In this case Validation Methods inside Beansn are gone... right? Why?

    Hello,
    You can tell to JSF that you fields are required only if the submit button was responsible for submiting the form :
    <h:form id="rmName">
    <h:selectOneMenu value="#{mybean.selectedCountry}" valueChangeListener="#{mybean.countryVLC}"
    onchange="this.form.submit();" >
    <f:selectItem itemName="select" itemValue=""/>
    <f:selectItems value="#{mybean.countriesMap}"/>
    </h:selectOneMenu>
    <h:inputText required=”#{!empty param[‘frmName:btnSave’]}” binding="#{mybean.mobileNo}"></h:inputText>
    <h:commandButton id="btnSave" value="btnSave"></h:commandButton>
    </h:form>

  • h:selectOneMenu and "value" attribute

    I have an issue with the <h:selectOneMenu> tag. On a page I've written, the select items are populated with a <f:selectItems> tag that is bound to a managed bean property with session scope which queries from a database table for the select items. The <h:selectOneMenu> value property - which determines the item that is selected - is bound to a property of a managed bean that has session scope.
    There is a button on the screen that causes navigation to a new screen. On this screen, the user can add an entry to the database table from which the <f:selectItems> are populated. The event handler for the second screen adds a new item to the database table and sets the property on the managed bean to that determines which item is selected on the previous screen to this new value.
    The problem I have is that the new item is added to the list, but it is not the selected item when the first screen is navigated back to. If I view the HTML code generated, none of the <option> tags contains the "SELECTED" property. Strangely, if I enter a new item that is less - alphabetically - than the existing items, it will be selected, but if I add an item that falls into the middle of the list or the end of the list alphabetically, it is not selected.
    I don't know what to do here. Is there some requirement about sorting the collection that backs the <f:selecteditems> facet? This doesn't seem likely since I've tried various sorts to figure this out and nothing has worked. Is there a known bug setting the value property of <h:selectOneMenu>?
    Any ideas?

    When your setting the value for the <h:selectOneMenu> make sure its a string!
    Here is a simple example
    (.jsp page)
    <h:selectOneMenu id="locationID" value="2">
       <f:selectItems value="#{LocationList.itemList}"/>
    </h:selectOneMenu>
    (HTML Code that gets generated from the .jsp page
    <select id="edit:locationID" name="edit:locationID" size="1">
       <option value="1">Anoka</option>
       <option value="2"  selected>MSO</option>
    </select>

  • Error  while working with JSF SelectOneMenu and JSTL forEach Tag

    Hello,
    I have set up few things in ArrayList in my contextListener as like below
    ServletContext context=event.getServletContext();
    List list=new ArrayList();
    list1.add("Honda");
    list1.add("Mazda");
    list1.add("eClipse");
    context.setAttribute("carList", list)
    I just wanted to display the list in my JSF page, I wrote the below statements in my JSF page
    <h:selectOneMenu value="{com.carSelection}">
    <c:forEach var="car" items="${applicationScope.carList}" >
    <f:selectItem itemLabel="${car}"/>
    </c:forEach>
    </h:selectOneMenu>
    I am getting the below exception
    org.apache.jasper.JasperException: /pages/protected/cmt/index.jsp(23,2) According to TLD or attribute directive in tag file, attribute itemLabel does not accept any expressions
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
    org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1124)
    org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:819)
    org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1512)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
    org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:838)
    org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1512)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
    org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator
    Could some one help to solve this error (Or) How should I display from my applicationScope list into MenuItems ?
    Edited by: Saravvij on Apr 9, 2008 8:37 PM
    Edited by: Saravvij on Apr 9, 2008 8:38 PM

    Hi,
    get your original message source from SXMB_MONI
    (right click - view source ) then paste your message to your message mapping (Test Tab) in the Integration Repository
    test your mapping and check if it's ok
    Regards,
    michal

  • H:selectOneMenu and its value parameter trouble

    Hello!
    I have a form in my jsp page ^
    <h:dataTable id="table" value="#{Reference.template.fields}" var="list" rowClasses="list_row_odd, list_row_even" columnClasses="align_right, align_left" width="100%" border="0" cellpadding="4" cellspacing="1">
                <h:column rendered="#{(list.label != 'code')}">
                  <h:outputText value="#{list.label}" escape="false"/>
                </h:column>
                <h:column rendered="#{(list.optionsSize < 1)&&(list.label != 'code')}">
                  <h:inputText id="ref_input" value="#{Reference.faculty}" readonly="true" rendered="#{list.label == '&#1060;&#1072;&#1082;&#1091;&#1083;&#1100;&#1090;&#1077;&#1090;'}" size="50"/>
                  <h:inputText id="ref_input_1" value="#{list.value}" rendered="#{(list.label != '&#1060;&#1072;&#1082;&#1091;&#1083;&#1100;&#1090;&#1077;&#1090;') && (list.value == '')}" size="50"/>
                  <h:inputText id="ref_input_2" value="#{list.value}" readonly="true" rendered="#{(list.label != '&#1060;&#1072;&#1082;&#1091;&#1083;&#1100;&#1090;&#1077;&#1090;') && (list.value != '')}" size="50"/>
                </h:column>
                <h:column rendered="#{(list.optionsSize > 0) && (list.label != 'code')}">
    // here is the problem -----------------------------
                  <h:selectOneMenu id="list" value="#{list.value}">
                    <f:selectItems value="#{list.options}" />
                  </h:selectOneMenu>
                </h:column>
                <h:column rendered="#{(list.label != 'code')}">
                  <h:outputText value="#{list.lov}" escape="false"/>
                </h:column>
              </h:dataTable>the trouble is if there is a value parameter, the form is submitted to server
    as empty one, if there isn't value parameter it works well.
    list.getValue - returns String
    and i strongly need to show the selected value!!!1
    Please help

    I'm not talking about JavaScript.
    I would like to write my own Java function:
    String formatStatus(String status, Date date) {
    If (status.equals("A"))
    return "Active from date " + date;
    else
    return "Not active";
    and then to replace inside my dataTable's column:
    <h:outputText id="text2" value="#{varpaketi.status}" />
    with:
    <h:outputText id="text2" value="#{pc_Paketi.formatStatus($status, $date)}" />
    where $status and $date are dataset variables which were displayed in column of my datatable.

  • Help with Custom Component: Ajax and ValueChangeListener

    Hello,
    I am trying to create a custom component that triggers an update via Ajax. However, I would also like to trigger a ValueChangeListener method from the same component, however I am unsure of how to obtain and trigger the ValueChangeEvent.
    The code I have so far in the Phase Listener is:
    private void handleAjaxRequest(PhaseEvent event) {
         FacesContext context = event.getFacesContext();
            HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
            Object object = context.getExternalContext().getRequest();
            if (!(object instanceof HttpServletRequest)) {
                return;
            HttpServletRequest request = (HttpServletRequest)object;
            HttpSession session =  request.getSession();
            String requestType = request.getParameter("jsflotRequestType");
            if (requestType != null && requestType.equalsIgnoreCase("jsflotchartValueChange")) {
                 //Trigger valueChangeEvents
                 log.info("Handling JSFlot Chart Value Change Event.");
    }What I am looking for though, is some information regarding how to obtain the ValueChangeListener from the request/session objects.
    The component tag is called like this:
    <jsflot:flotChart id="valueTimeChart"
         value="#{chartMbean.chartSeries}"
         valueChangeListener="#{chartMbean.valueChangeListener}"Any help would be greatly appreciated!

    The field calculation order was not in the correct order, had a devil of a time figuring out how to get to it, in Acrobat X.
    My check boxes for shipping have the same name field but I don't see a tab for export value for the check boxes, and I have no idea how to implement your suggestions for a switch or if statement or what fields to attach them to. 
    My amatuer attempt at a shipping formula follows, I don't know if I can use a range for event value, or where to put the script, if it is even correct.
    if(event.value == "<25.01")
        nShipFee = 06;
    else if(event.value == "25.01 - 75")
        nShipFee = 11.50;
    else if(event.value == "75.01 - 125")
        nShipFee = 15;
    else if(event.value == "125.01 - 200")
        nShipFee = 20;
    else if(event.value == "200.01 - 300")
        nShipFee = 25;
    else if(event.value == "300.01 - 400")
        nShipFee = 30;
    else if(event.value == ">400")
        nShipFee = 50;

  • Af:forEach - and ValueChangeListener -11g

    Okay, change my code to use af:forEach instead of af:iterator.
    My jsff
    <af:forEach items='#{pageFlowScope.managedBean.flexFieldsListGlobalDataElements}' var="list" varStatus="vs">
    <af:switcher facetName="#{list.attributeType}" id="s5">
    <f:facet name="INPUT">
    <af:inputText label="#{list.label}" id="it${vs.index}" value="#{list.value}" autoSubmit="true" rendered="#{list.displayed}"
    valueChangeListener="#{pageFlowScope.managedBean.valueChangeListener}"></af:inputText>
    </f:facet>
    </af:switcher>
    </af:forEach>
    <!-- Test Button -->
    <af:commandButton text="commandButton 1" id="cb3" action="#{pageFlowScope.managedBean.cb3_action}"/>
    Bean (extract):
    public void valueChangeListener(ValueChangeEvent valueChangeEvent) {
    System.out.println("valueChangeListener");
    Object o = valueChangeEvent.getSource();
    if (o instanceof RichInputText) {
    RichInputText r = (RichInputText)o;
    System.out.println(r.getId());
    System.out.println("RichInputText");
    UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent("it3");
    if (component != null) {
    System.out.println("REfresh....");
    AdfFacesContext context = AdfFacesContext.getCurrentInstance();
    context.addPartialTarget(component);
    public String cb3_action() {
    UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent("it3");
    if (component != null) {
    System.out.println("REfresh....");
    AdfFacesContext context = AdfFacesContext.getCurrentInstance();
    context.addPartialTarget(component);
    return null;
    When the ValuechangeListener is called - hte PPR functionality doesn't start up. But if I press the test button - the PPR work. Notice the beancode. It is exactly the same - when it comes to PPR.
    What I want to achieve is, when one field is updated - forcing another one to refresh.
    Any suggestions?
    Rgds, Henrik

    Hi Timo,
    Actually - with the forEach - the ${vs.index} - works!
    If I get the compoent_id via getSource - and use that id in the PPR partialTarget - it wont work. If I use Firebug to identify the id of my componet - and use this with PartielTarget - it wont work.
    So - please tell me - how do I get a component_id I can use with partielTarget or some other method that can trigger the refresh of an UI componenet.
    Thanx

  • SelectOneMenu and commandButtons

    Hi Iam using J2EE 1.4 and jsf1.0. I have the following code
    <h:selectOneMenu id="groups" value="#{UserBean.selectedGroup}">
    <f:selectItems value="#{UserBean.groupsList}"/>
    </h:selectOneMenu>
    <h:commandButton id="showGroupMembers" value="Show Members" action="#{UserBean.showGroupMembers}"/>
    <!-- backing bean -->
    groupsList.add(new SelectItem(groupName,groupName)); // groupName is a String
    public ArrayList getGroupsList()
    FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("dd"));
    return groupsList;
    public void setGroupsList(ArrayList list)
    try
    groupsList = list;
    catch(Exception e)
    FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(e.getMessage()));
    public SelectItem getSelectedGroup()
    return selectedGroup;
    //return new SelectItem((String)selectItemsList.get(0),(String)selectItemsList.get(0));
    public void setSelectedGroup(SelectItem group)
    try
    selectedGroup = group;
    catch(Exception e)
    FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(e.getMessage()));
    When I press the command buttons I get a message saying conversion error occured.But Iam not sure
    either it is the conversion for selectedGroup or the ArrrayList . From other threads about this topic I learned that Strings should be ok to use with selectItem. Where am I going wrong.
    thanx all for ur help
    phani

    Hi sorry .
    I was blindly following some example I found on the net. The selectedGroup must be String . Then everything works
    sorry for the trouble
    phani

  • DataTable, pagination, and valuechangelistener.

    Hi, I'm working with dataTables and have a behavior issue I can't seem to find a solution to. I start with the following conditions:
    1) I want to use pagination to control the size of the table on the form,
    2) I do NOT want to submit (immediate) after each user entry (don't like the look).
    That said I find that when I change textFields on pages 1-3 and submit while page three is showing, only the textFields that were changed on page 3 fire the valuechangelistener. Those textFields changed on page one and two are ignored. Should the user navigate to a new web page those changes on table page 1&2 are lost.
    I am using virtual forms to control what is submitted when but cannot get inside the pagination controls to make all textField changes (regardless of page) fire at the same time.
    Anyone have a solution to this?
    Thanks.

    Sorry.
    it was a error on my side. every time i was getting just 10 rows like
    for (i=0; i< dataTable.rows;i++)
    instead, i needed to use for (i=0; i < (dataTable.getFirst+dataTable.rows);i++)HTH someone else.
    Thanks

  • SelectOneMenu and Enums

    Have anyone got enums working with selectOneMenu components?
    I am having problems:
    Error Msg: "Validation Error "enum_menu": Value is not a valid option."
    Data is displayed correcting via the converter and the item selected is correct, but on binding I have problems - no exception, just the error message above.
    The converter getAsObject takes the enum value which is the name of the enum and creates a enum object which is returned, its as this point it goes wrong.
    public Object getAsObject(FacesContext context, UIComponent comp, String value) throws ConverterException {
              System.out.println(value);
         Class enumType = comp.getValueBinding("value").getType(context);
         System.out.println(Enum.valueOf(enumType, value));
         return Enum.valueOf(enumType, value);          
    <h:selectOneMenu id="m2" value="#{riskView.breachActionEnum}">
      <f:selectItems value="#{bean.breachActions}"/>
    </h:selectOneMenu>Any ideas, this is driving me nuts.
    Thanks

    from my understanding and i could be wrong value changed listeners do not handle navigation
    only actions do
    so you might have to do this
    FacesContext.getCurrentInstance().getExternalContext().redirect("your url");
    within you value change listener

  • SelectOneMenu and custom object

    Hi everybody,
    i have problems using selectOneMenu component.
    <h:panelGroup rendered="#{Navi.rendered}">
                        <h:selectOneMenu id="selPerson" value="#{Navi.user}">
                             <f:selectItems value="#{Navi.list}"/>
                        </h:selectOneMenu>
                   </h:panelGroup>Here is the code from the backing bean:
    private List list;
    private User user;
    public List getList() {
              if (list == null){
                   loadDefault();
              return list;
         public void setList(List list) {
              this.list = list;
         public User getUser() {
              return user;
         public void setUser(User name) {
              this.user = name;
         }The list is loaded from db as follows:
    while (result.next()){
         User user = (User) result.get(0);
         userlist.add(new SelectItem(user,user.getFirstname()+ " 
            "+user.getSurname(),user.getScreenName()));
    }I get a validation error when trying to get the value from the list. Can anybody help? Regards,
    ak

    Hi Sushil,
    To write to the activity stream, these are the things you need
    1) A service definition in service-definition.xml . Similar to here http://docs.oracle.com/cd/E15523_01/webcenter.1111/e10148/jpsdg_svc_intro.htm#JPSDG506
    2) Use the ActivityStreaming API to publish the event. (Note: I have only tried this from within WebCenter Portal so I can't be sure how the API may be called remotely)
         a) oracle.webcenter.activitystreaming.ActivityStreamingService.createActivityElement() to construct the activity element
         b) oracle.webcenter.activitystreaming.ActivityStreamingService.publish() to publish the activity element.
    I can try and distil my code into a sample later this week.

Maybe you are looking for

  • Looking for help with movie loading in a different spot every time page reloads.

    Hello, I have a Flash movie that I need to jump to a one of 6 chosen frames when say a user hits the back button or home in the site. I just dont want the same user seeing the flash movie replay in the same spot everytime they go back to home. ANY he

  • Performance problems with java sockets

    Hi , I written a server class that simply writes the numbers and the client simply reads those numbers and prints them. When I run the both client and server on tha same machine there is no data loss found. But when I run the server on different mach

  • Ati 7950 Card and Premiere Pro CC

    I see this card is not on Adobe's list of supported cards. can anyone from Adobe tell me if it is likely to be supported and Is anyone here using it with CC and if so how is it performing? We can't easily get the Mac version of the GTX 680 card here

  • How to edit SubCA duration on a Standalone AD Root CA?

    I have a standalone Root CA built on 20012 R2 and also built a separate standalone Subordinate CA on 2012 R2. I have set the Root CA duration to 20 years and now want the Root CA to sign the Sub CA request file. I have done it successfully, but the d

  • Use extends and implements or not?

    What is considered a better way of implementing classes? with the use of extends and/or implements or not? ex: public class TabPanel extends JPanel implements ActionListeneror have it return the needed Type ex: public class TabPanel implements Action