5 Replies Latest reply on Nov 9, 2011 1:19 PM by mcmurdosound

    Setting values in bean from input field in popuppanel

    mpgong

      Hello,

       

      I'm trying to get the values out of a popuppanel and set in my bean but for some odd reason the following doesn't pull the values i enter in the input fields.

       

                   <rich:popupPanel id="resForm">

                      <f:facet name="controls">

                          <h:outputLink

                              onclick="#{rich:component('resForm')}.hide(); return false;">X</h:outputLink>

                      </f:facet>

                      <h:panelGrid columns="5"

                          columnClasses="etc-popup-label,etc-popup-value,etc-userfind,etc-popup-label,etc-popup-value">

                          <h:outputLabel value="Resource Name:" />

                          <h:inputText value="#{ResourceBean.name}" id="resourceName" />

                          <a4j:commandLink styleClass="no-decor" onclick="">

                              <h:graphicImage value="/resources/images/userfind.png" />

                          </a4j:commandLink>

                          <h:outputLabel value="Current ETC:" />

                          <h:inputText value="#{ResourceBean.curr_etc}" id="currentETC" />

                      </h:panelGrid>

                      <a4j:commandButton value="Add"

                          actionListener="#{ResourceBean.addResource}" execute="@form"

                          render="ETC-panel"

                          oncomplete="#{rich:component('resForm')}.hide(); return false;">

                      </a4j:commandButton>

                  </rich:popupPanel>

       

      The ResourceBean.addResource is invoked but the value in ResourceBean.name is blank and ResourceBean.curr_etc remains 0.  Any thoughts as to what i'm doing wrong here.

       

      Thanks

        • 1. Re: Setting values in bean from input field in popuppanel
          mcmurdosound

          There is no form. I think like in rf 3.3.x you have to place a form inside of your modal / popuppanel to surround the input fields and buttons.

          • 2. Re: Setting values in bean from input field in popuppanel
            mpgong

            Actually, i have the h:form around that along with other components.  I'm going to see if i can get the popup values set with the other components removed and see if somehow i messed things up when i start having a lot of things going on.'

             

            Thanks for the reply.

            • 3. Re: Setting values in bean from input field in popuppanel
              mpgong

              Here is the page after i stripped it down to just the popup.

               

               

              <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                  xmlns:ui="http://java.sun.com/jsf/facelets"
                  xmlns:h="http://java.sun.com/jsf/html"
                  xmlns:f="http://java.sun.com/jsf/core"
                  xmlns:a4j="http://richfaces.org/a4j"
                  xmlns:rich="http://richfaces.org/rich"
                  xmlns:s="http://jboss.com/products/seam/taglib">
              
                  <h:outputStylesheet library="css" name="projectDetails_style.css"
                      target="head" />
                  <h:outputStylesheet>
                      .rf-edt-hdr-c {
                            border-right: none !important;        
                            border-bottom: none !important;            
                      }
              
                      .rf-edt-c {        
                            height: 100% !important;        
                           border-right: none !important;        
                            border-bottom: none !important;        
                      }
              
                      .rf-edt-cnt td {
              
                            border-bottom: 1px solid #9FC0E9;    
                            border-right: 1px solid #9FC0E9;        
                      }
              
                      .rf-edt-c-cnt {
                          white-space: normal;
                      }
              
                      .extdt-hsep {
                          display: none !important;
                      }
              
                      a.no-decor>img {
                          border: none;
                      }
                  </h:outputStylesheet>
                  <h:body onload="#{rich:component('addResourcePane')}.show();">
                  <h:form id="popupForm">
                  <rich:panel bodyClass="panel-custom-body">
              
                          <rich:popupPanel id="addResourcePane"
                              header="Task To Complete" modal="true" moveable="true"
                              width="620" height="330">
                              <f:facet name="controls">
                                  <h:outputLink
                                      onclick="#{rich:component('addResourcePane')}.hide(); return false;">X</h:outputLink>
                              </f:facet>
                              <rich:panel id="ETC-panel" bodyClass="etc-panel-body">
              
                                  <h:panelGrid columns="3">
                                      <rich:panel styleClass="panel-spacer-etc"></rich:panel>
                                      <rich:panel styleClass="panel-spacer-etc"></rich:panel>
                                      <h:panelGrid columns="5"
                                          columnClasses="etc-popup-label,etc-popup-value,etc-userfind,etc-popup-label,etc-popup-value">
                                          <h:outputLabel value="Resource Name:" />
                                          <h:inputText value="#{WTF.name}" id="name"></h:inputText>
                                          <a4j:commandLink styleClass="no-decor" onclick="">
                                              <h:graphicImage value="/resources/images/userfind.png" />
                                          </a4j:commandLink>
                                      </h:panelGrid>
                                  </h:panelGrid>
                              </rich:panel>
                              <a4j:commandButton value="Add Resource" actionListener="#{WTF.submitMe()}">                            
                                      </a4j:commandButton>
                          </rich:popupPanel>
              
              
                  </rich:panel>
                  </h:form>
                  </h:body>
              </ui:composition>
              

               

              and the bean

               

               

              package com.lmco.ibe.ims.status.model.beans;
              
              import javax.faces.bean.ManagedBean;
              import javax.faces.event.ActionEvent;
              
              @ManagedBean(name="WTF")
              public class TestSubmit {
              
                  private String name;
              
                  public TestSubmit() {
                      // TODO Auto-generated constructor stub
                  }
              
                  public String getName() {
                      return name;
                  }
              
                  public void setName(String name) {
              
                      this.name = name;
                  }
              
                  public void submitMe(ActionEvent evt){
                      System.out.println("I SHOULD HAVE SUBMITTED");
                      System.out.println("I got the name = "+name);
              
                      //return "";
                  }
              
              }
              

               

               

              When i run this it doesn't work, and the name is null but if i remove the popupPanel tag (shown below) it works fine and whatever i enter in the input field the bean sees.  Any thoughts as to what i'm doing wrong here.

               

              Thanks

               

               

              <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                  xmlns:ui="http://java.sun.com/jsf/facelets"
                  xmlns:h="http://java.sun.com/jsf/html"
                  xmlns:f="http://java.sun.com/jsf/core"
                  xmlns:a4j="http://richfaces.org/a4j"
                  xmlns:rich="http://richfaces.org/rich"
                  xmlns:s="http://jboss.com/products/seam/taglib">
              
                  <h:outputStylesheet library="css" name="projectDetails_style.css"
                      target="head" />
                  <h:outputStylesheet>
                      .rf-edt-hdr-c {
                            border-right: none !important;        
                            border-bottom: none !important;            
                      }
              
                      .rf-edt-c {        
                            height: 100% !important;        
                           border-right: none !important;        
                            border-bottom: none !important;        
                      }
              
                      .rf-edt-cnt td {
              
                            border-bottom: 1px solid #9FC0E9;    
                            border-right: 1px solid #9FC0E9;        
                      }
              
                      .rf-edt-c-cnt {
                          white-space: normal;
                      }
              
                      .extdt-hsep {
                          display: none !important;
                      }
              
                      a.no-decor>img {
                          border: none;
                      }
                  </h:outputStylesheet>
                  <h:body>
                  <h:form id="popupForm">
                  <rich:panel bodyClass="panel-custom-body">
                              <rich:panel id="ETC-panel" bodyClass="etc-panel-body">
              
                                  <h:panelGrid columns="3">
                                      <rich:panel styleClass="panel-spacer-etc"></rich:panel>
                                      <rich:panel styleClass="panel-spacer-etc"></rich:panel>
                                      <h:panelGrid columns="5"
                                          columnClasses="etc-popup-label,etc-popup-value,etc-userfind,etc-popup-label,etc-popup-value">
                                          <h:outputLabel value="Resource Name:" />
                                          <h:inputText value="#{WTF.name}" id="name"></h:inputText>
                                          <a4j:commandLink styleClass="no-decor" onclick="">
                                              <h:graphicImage value="/resources/images/userfind.png" />
                                          </a4j:commandLink>
                                      </h:panelGrid>
                                  </h:panelGrid>
                              </rich:panel>
                              <a4j:commandButton value="Add Resource" actionListener="#{WTF.submitMe()}">                            
                                      </a4j:commandButton>
              
              
              
                  </rich:panel>
                  </h:form>
                  </h:body>
              </ui:composition>
              
              • 4. Re: Setting values in bean from input field in popuppanel
                mpgong

                Ok, figured the issue.  I didn't have the domElementAttachment="parent" attribute in the popupPanel.  After adding that everything works fine now.

                • 5. Re: Setting values in bean from input field in popuppanel
                  mcmurdosound

                  "domElementAttachment="parent""

                   

                  or you put the h:form in your popupPanel:

                  <h:form id="mainForm>

                  ... some stuff

                   

                  </h:form>

                   

                   

                  <rich:popupPanel id="addResourcePane"
                                  header="Task To Complete" modal="true" moveable="true"
                                  width="620" height="330">

                                  <f:facet name="controls">
                                      <h:outputLink
                                          onclick="#{rich:component('addResourcePane')}.hide(); return false;">
                  X</h:outputLink>
                                  </f:facet>

                            <h:form id="popupForm">

                       ...

                  </rich:popupPanel>