9 Replies Latest reply on May 23, 2011 2:17 AM by Rahul Tomar

    rich:select valuechange event (richfaces 4)

    Mohammad Weshah Novice

      i notice that the rich:select is not support the valuechange event , please confirm

        • 1. Re: rich:select valuechange event (richfaces 4)
          iabughosh Master

          same here, i don't know if this is a bug but we will wait RF Experts to reply, anyway there is a walkaround, you can use a4j:ajax :

          <rich:select value="#{user.name}" 

            id="selectId">

            <a4j:ajax event="change" execute="@this" listener="#{user.myAjaxListener}"/>

            <f:selectItem itemLabel="Value 1" itemValue="1"/>

            <f:selectItem itemLabel="Value 2" itemValue="2"/>

            </rich:select>

           

          public void myAjaxListener(AjaxBehaviorEvent abe) {

            //do some

            }

           

          regards.

          • 3. rich:select valuechange event (richfaces 4)
            Rahul Tomar Newbie

            Hi Ibrahim,

             

            the way you said for using the listener is correct, but I found one problem with this that when I am changing my value from the list the listener alway took the first name from the list, it never able to go to the selected one. Do you have any solution for this ?

            Thanks for the help....

            • 4. rich:select valuechange event (richfaces 4)
              iabughosh Master

              welcome to the forum Tomar, i'm using the same code and it works fine with me, please post your xhtml file.

              • 5. Re: rich:select valuechange event (richfaces 4)
                Rahul Tomar Newbie

                Hi,

                 

                here is my xhtml file

                 

                <f:view>

                      <ui:composition>

                 

                         <ui:define>   

                         <div id="hauptfenster_inhalt">

                             <h:form id="recipientList">

                 

                              <rich:dataTable id="messageRecipients_edit" rendered="#{alarmService.doEdit}" value="#{alarmService.messageRecipientsList}" var="messageRecipients_edit" style="margin-top:5px;" rowClasses="richrow1,richrow2" rows="10">

                                <rich:column>

                                   <f:facet name="header">

                                      <h:outputText value="#{text['messageRecipients.recipient']}" />

                                   </f:facet>

                                   <h:message for="myComboBox" styleClass="fieldError" />

                                   <rich:select id="myComboBox" defaultLabel="#{messageRecipients_edit.recipient}"

                                       enableManualInput="true">

                                      <a4j:ajax event="change" render="messageRecipients_edit" execute="@this" listener="#{alarmService.addUserDetails}"/>

                                      <f:selectItems value="#{alarmService.users}" var="person" itemValue="#{person}" itemLabel="#{person.username}"/>                                                               

                                        <v:commonsValidator type="required" arg="#{text['messageRecipients.recipient']}" />                                               

                                    </rich:select>                   

                                </rich:column>

                                <rich:column>

                                    <f:facet name="header">

                                        <h:outputText value="#{text['messageRecipients.type']}" />

                                    </f:facet>                   

                                    <h:selectOneMenu id="selectType" value="#{messageRecipients_edit.type}" styleClass="standardInput" style="width:105px;">

                                      <f:selectItem itemValue="U" itemLabel="#{text['label.user']}" />

                                      <f:selectItem itemValue="F" itemLabel="#{text['label.file']}" />

                                      <f:selectItem itemValue="S" itemLabel="#{text['label.screen']}" />                     

                                    </h:selectOneMenu> 

                                </rich:column>

                                <rich:column>

                                    <f:facet name="header">

                                        <h:outputText value="#{text['messageRecipients.target']}" />

                                    </f:facet>

                                    <h:selectOneMenu id="selectTarget" value="#{messageRecipients_edit.target}" styleClass="standardInput" style="width:105px;">

                                      <f:selectItem itemValue="E" itemLabel="#{text['label.email']}" />

                                      <f:selectItem itemValue="SMS" itemLabel="#{text['label.sms']}"  />                     

                                    </h:selectOneMenu>

                                </rich:column>

                                <rich:column>

                                    <f:facet name="header">

                                        <h:outputText value="#{text['label.Address']}" />

                                    </f:facet>

                                    <h:message for="recipient" styleClass="fieldError" />                                                                

                                      <h:inputText id="recipient" value="#{messageRecipients_edit.address}" required="true">

                                        <v:commonsValidator type="required" arg="#{text['label.address']}" />

                                      </h:inputText>                                         

                                </rich:column>               

                                <rich:column>

                                    <f:facet name="header">

                                        <h:outputText value="#{text['label.Alarm']} #{text['label.enabled']}" />

                                    </f:facet>

                                    <h:selectBooleanCheckbox value="#{messageRecipients_edit.alarm_enabled}" disabled="false" />

                                </rich:column>

                                <rich:column>

                                    <f:facet name="header">

                                        <h:outputText value="#{text['label.Warning']} #{text['label.enabled']}" />

                                    </f:facet>

                                    <h:selectBooleanCheckbox value="#{messageRecipients_edit.warning_enabled}" disabled="false" />

                                </rich:column>               

                                <rich:column>

                                    <f:facet name="header">

                                        <h:outputText value="#{text['button.delete']}" />

                                    </f:facet>

                                    <a4j:commandLink action="#{alarmService.deleteRecipient}" render="messageRecipients_edit"

                                            onclick="if(!confirm('Are you sure you want to delete ?')) {form.reset(); return false;}"

                                            oncomplete="alert('Deleted!')" ajaxSingle="true">

                                        <f:setPropertyActionListener target="#{alarmService.recipient}" value="#{messageRecipients_edit.recipient}"/>   

                                        <h:outputText value="#{text['button.delete']}" />                       

                                    </a4j:commandLink>

                                </rich:column>  

                              </rich:dataTable>

                        </h:form>

                        </div>

                 

                    </ui:define>

                 

                </ui:composition>

                 

                </f:view>

                • 6. rich:select valuechange event (richfaces 4)
                  iabughosh Master

                  i've noticed that your :

                   

                  <rich:select id="myComboBox" defaultLabel="#{messageRecipients_edit.recipient}"

                                         enableManualInput="true">

                   

                  doesn't have a value attribute, add a value attribute & try again.

                  • 7. rich:select valuechange event (richfaces 4)
                    Rahul Tomar Newbie

                    thanks for the reply...

                     

                    I tried the code by adding the value attribute even then in every selection the getRowIndex() is 0.

                    • 8. rich:select valuechange event (richfaces 4)
                      iabughosh Master

                      rich:select id="myComboBox" defaultLabel="#{messageRecipients_edit.recipient}"

                                             enableManualInput="true" value="#{bean.property}">

                       


                      try printing your #{bean.property}, is your getRowIndex() in the value attribute ? if no where did you use this value ?.

                      • 9. Re: rich:select valuechange event (richfaces 4)
                        Rahul Tomar Newbie

                        I found my mistake... I was using in <f:selectItems> both itemValue and value attributes, which I think is not correct way. Now after changing that and by using only value attribute into it my programme is working well. Now even the valueChangeListener of <rich:select> is starts working.

                         

                        Thanks  for your wonderfull time.....