0 Replies Latest reply on Jul 31, 2011 3:23 PM by Pavel Mart

    Richfaces4 rich:select with converter value is not populated

    Pavel Mart Newbie

      Hello Dear Community,

       

      I faced with the problem with populating values for a select component.

      When a page is loaded all values are populated but the values in selects. I added a button to the page which simply re-renders page content. After that the value appears in the select component. Do I do something wrong or it is a problem with component?

       

      Please, find the code below

       

      JSF page looks like the following

      ====================================================================================

      <ui:composition template="/WEB-INF/template/main.xhtml"

                      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:rich="http://richfaces.org/rich"

                      xmlns:a4j="http://richfaces.org/a4j">

          <ui:define name="content">

              <f:view id ="main_view" contentType="text/html">

              <h:form id="req_open_pro_main_form">

                  <h:panelGroup id="mainPanel">

                      <h:panelGrid columns="1">

                          <h:panelGrid columns="2">

                              <h:outputLabel for="name" value="#{msg['company.name']}"/>

                              <h:outputText id="name" value="#{reqOpenProcController.company.organizationName}"/>

                          </h:panelGrid>

                          <rich:message for="name" styleClass="err"/>

                      </h:panelGrid>

      .................................

       

                      <h3><h:outputText value="#{msg['address']}"/></h3>

                      <h:panelGrid columns="3" columnClasses="ifc20,ifc20,ifc20">

                          <h:panelGroup>

                              <h:outputLabel for="zip" value="#{msg['zip']}" styleClass="inputLable"/>

                              <h:inputText id="zip" value="#{reqOpenProcController.company.address.postalCode}"/>

                          </h:panelGroup>

       

                          <h:panelGrid columns="2">

                              <h:outputLabel for="country" value="#{msg['country']}" styleClass="inputLable"/>

                              <rich:select enableManualInput="true" defaultLabel="#{msg['start.typing.for.select']}"

                                           id="country" converter="com.enfasis.eced.common.controller.converter.CountryConverter"

                                           value="#{reqOpenProcController.company.address.country}">

                                  <f:selectItems value="#{countryList.list}"/>

                              </rich:select>

                          </h:panelGrid>

       

                          <h:panelGroup>

                              <h:outputLabel for="region" value="#{msg['region']}" styleClass="inputLable"/>

                              <h:inputText id="region" value="#{reqOpenProcController.company.address.region}"/>

                          </h:panelGroup>

      ..........................................

                      </h:panelGrid>

       

                      <h:panelGroup id="buttonPanel">

                          <h:commandButton value="#{msg['cancel']}" action="#{reqOpenProcController.cancel}" execute="@this"/>

                          <h:commandButton value="#{msg['save']}" action="#{reqOpenProcController.save}"/>

                          <a4j:commandButton value="Reload" render="mainPanel"/>

                      </h:panelGroup>

                  </h:panelGroup>

              </h:form>

              </f:view>

          </ui:define>

      </ui:composition>

      ==================================================================================

       

      If i push the  'Reload' button the the page the value for country is going to appear

      The code for the back-end bean is below:

      ==================================================================================

      @ManagedBean(name = "reqOpenProcController")

      @ViewScoped

      public class ReqOpenProcDocumentController extends BaseController {

          Logger logger = Logger.getLogger(ReqOpenProcDocumentController.class.getName());

       

          @ManagedProperty(value = "#{userSession}")

          private UserSessionController userSessionController;

       

          private Document document;

       

      .............................................

       

          private Company company;

       

          @PostConstruct

          private void init() {

              company = new Company();

              try {

                  BeanUtilsBean.getInstance().copyProperties(company, userSessionController.getUser().getCompany());

              } catch (IllegalAccessException e) {

                  logger.info(e.getMessage());

              } catch (InvocationTargetException e) {

                  logger.info(e.getMessage());

              }

          }

       

          public Company getCompany() {

              return company;

          }

       

          public void setCompany(Company company) {

              this.company = company;

          }

       

          public UserSessionController getUserSessionController() {

              return userSessionController;

          }

       

          public void setUserSessionController(UserSessionController userSessionController) {

              this.userSessionController = userSessionController;

          }

       

          public Document getDocument() {

              return document;

          }

       

          public void setDocument(Document document) {

              this.document = document;

          }

       

          private void prepareData() {

      ...................

          }

       

       

          public String save() {

              prepareData();

              return "document_list";

          }

       

          public String cancel() {

              return "document_list";

          }

      }

      ======================================================================

       

      Navigation rule looks like the following:

       

      ======================================================================

          <navigation-rule>

              <navigation-case>

                  <from-outcome>req_open_proc</from-outcome>

                  <to-view-id>/pages/req_open_proc.xhtml</to-view-id>

                  <redirect/>

              </navigation-case>

          </navigation-rule>

      ======================================================================

       

      the code for the link to the page and the appropriate method of the back-end been look like the following

      ======================================================================

       

          <rich:menuItem  label="#{msg['open.procedure.request']}"

                action="#{menuController.reqOpenPro}" icon="/resources/images/create_doc.gif">

          </rich:menuItem>

       

      @ManagedBean(name = "menuController")

      @SessionScoped

      public class MenuController extends BaseController {

      ...............................

          public String reqOpenPro() {

              return "req_open_proc";

          }

      ...............................

      }

      ======================================================================

       

      Could you please tell me what do I do wrong and what can I do to make it work properly. Thanks