3 Replies Latest reply on Dec 17, 2009 5:24 AM by ilya_shaikovsky

    inplaceSelect displaying items problem

      Hi guys,

       

      I have a little problem with rich:inplaceSelect input. The code:
      <rich:inplaceSelect value="#{country}" showControls="true" id="countrySelect">
           <f:facet name="controls">

                <h:panelGrid>

                     <a4j:commandButton value="Save" onclick="#{rich:component('countrySelect')}.save();" ajaxSingle="true">
                          <a4j:support event="oncomplete" action="#{bean.saveCountry}" reRender="countrySelect"/>
                     </a4j:commandButton>
                     <a4j:commandButton value="Cancel" onclick="#{rich:component('countrySelect')}.cancel();"
                          reRender="countrySelect" ajaxSingle="true"/>
                </h:panelGrid>

           </f:facet>
           <f:selectItems value="#{bean.countryList}"/>
      </rich:inplaceSelect>

       

      When I choose country from items list it(list) dissapears what is correct. If I click 'Save' or 'Cancel' button after, the javascript function onclick works fine and bean is updated also inputSelect loo,  but somehow after reRender action items list shows again . It dissapears only when I click it. Maybe you had a problem like this on your side?


      inplaceSelect.JPG

        • 1. Re: inplaceSelect displaying items problem
          ilya_shaikovsky
               <h:form>
                    <h:panelGrid columns="3" width="500px;">
                         <h:outputText value="Current State:"/>
                         <rich:inplaceSelect value="#{inplaceComponentsBean.inputValue}"
                              defaultLabel="Click here to edit" showControls="true"
                              controlsHorizontalPosition="left" controlsVerticalPosition="bottom"
                              id="inplaceSelect">
                              <f:facet name="controls">
                                   <button onmousedown="#{rich:component('inplaceSelect')}.save();"
                                        type="button">Save</button>
                                   <button onmousedown="#{rich:component('inplaceSelect')}.cancel();"
                                        type="button">Cancel</button>
                              </f:facet> 
                              <f:selectItems value="#{capitalsBean.capitalsOptions}" />
                              <a4j:support event="onviewactivated" reRender="output, inplaceSelect" />
                         </rich:inplaceSelect>
                         <h:outputText id="output"
                              value="Current State Capital: #{inplaceComponentsBean.inputValue}"
                              style="font-weight:bold;" />
                    </h:panelGrid>
               </h:form>

          this modified code from demo looks fine for me and also stores value in the model and reRenders output and itself.

           

          The first problems with your code that it sends two request in order to just store value.. Maybe it's not related to actual issue - but not looks good at all.

          • 2. Re: inplaceSelect displaying items problem

            Hi Ilya,

             

            Thanks for replay. Unfortunately it's not working with mine ( like I want it to works ). Here you can see bean code for this country input:

             

            public class Bean {

            ...


            public void setCountry(String country) {
                 this.country = country;
            }
            public String getCountry() {
                 country = user.getCountry();
                 return country;

            }
            public void saveCountry() {
                 String newCountry = country;
                 String oldCountry = getCountry();
                 try {
                      if(!newCountry.equals(oldCountry)) {
                           user.setCountry(newCountry);
                           saveChange(newCountry, oldCountry);
                      }
                 } catch(Exception ex) {
                 }
            }

             

            What I need on 'Save' button click, is to update 'user' EntityBean and to save this change in another entity ("saveChange...").

            The problem with demo code is that when I click 'Cancel' it's updating anyway 'user' bean. This is the problem when i.e. someone else will save new value for this input before I click 'Cancel'. With my code it's returning actual database/entity user.country value what is perfect for me.

            I just started with inplaceInputs and Selects so maybe so far I don't know the tricks.

            • 3. Re: inplaceSelect displaying items problem
              ilya_shaikovsky

              thanks again. I'm filled one more issue:

              https://jira.jboss.org/jira/browse/RF-8220

               

              And pay attention that I added workaround which should be helpfull for you.