0 Replies Latest reply on Oct 20, 2011 1:55 PM by kapil29

    Problem while saving the data using Modal Panel wizard

    kapil29

      Hi,

       

      I am creating the modal panel wizard which contains the three forms in it. I have the following flow for dispaying the modal panel.

       

      1.  I have one data table containing some data in it and having one action column which contains the link to open the Modal panel ("Show New Tag).

      2.  When click on the Show New Tag link, the modal panel poups up and displaying another data table inside it.

      3.  At the bottom of the data table inside the modal panel, I have the link to go on the next form i..e "Create New Form". When i click on it, the new form shows up properly. (Modal Panel Wizard)

      4.  But the problem which i am facing is,  when I entered some data inside the new form and click on the submit button, then all the bean properties values are set to null values when i retrieving it in my controller class to save the same in the Data base.

       

      Please find the below code:

       

      1. Main data table code snippet for opening the Modal Panel from the Action column:

       

      <rich:dataTable

      ....

      ..

      <rich:column id="actionColumn" >

       

           <f:facet name="header">

                <h:outputText value="Actions"/>

           </f:facet>

       

           <a4j:commandLink value="Show New Tags" ajaxSingle="true"

                               action="#{projectController.showTagAction}"

                               oncomplete="Richfaces.showModalPanel('panel');"

                               reRender="panel"/>

       

      </rich:column>

      </rich:dataTable>

       

       

      2. Modal Panel code when I click on the "Show New Tags"  link from the main data table.

       

      <f:subview id="modal_panel"

              xmlns="http://www.w3.org/1999/xhtml"

              xmlns:c="http://java.sun.com/jstl/core"

              xmlns:ui="http://java.sun.com/jsf/facelets"

              xmlns:f="http://java.sun.com/jsf/core"

              xmlns:h="http://java.sun.com/jsf/html"

              xmlns:rich="http://richfaces.org/rich"

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

       

          <a4j:outputPanel layout="block" id="edituserouter">

              <rich:modalPanel id="panel" width="800" height="400">

                  <f:facet name="header">

                      <h:panelGroup>

                          <h:outputText value="Modal Panel" />

                      </h:panelGroup>

                  </f:facet>

       

                  <f:facet name="controls">

                      <h:panelGroup>

                          <h:graphicImage value="/images/icon_close.gif" styleClass="hidelink" id="hidelink"/>

                          <rich:componentControl for="panel" attachTo="hidelink" operation="hide" event="onclick"/>

                      </h:panelGroup>

                  </f:facet>

       

                  <h:panelGrid id="wizardPanelGroup">

                      <a4j:include viewId="#{tagNewBean.viewId}" />

                  </h:panelGrid>

       

              </rich:modalPanel>

        </a4j:outputPanel>

      </f:subview>

       

       

      3. Create New Form (When navigating from the Wizard)

       

      <h:panelGrid xmlns="http://www.w3.org/1999/xhtml"

              xmlns:c="http://java.sun.com/jstl/core"

              xmlns:ui="http://java.sun.com/jsf/facelets"

              xmlns:f="http://java.sun.com/jsf/core"

              xmlns:h="http://java.sun.com/jsf/html"

              xmlns:rich="http://richfaces.org/rich"

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

       

       

              <a4j:keepAlive beanName="tagNewBean"/>

       

              <h:panelGrid columns="2" cellpadding="10" cellspacing="10" >

                  <h:panelGroup>

                      <h:outputText id="tag_name_lebel" value="Name: " />

                  </h:panelGroup>

       

                   <h:panelGroup>

                      <h:inputText id="tag_name" value="#{tagNewBean.name}" valueChangeListener="#{tagNewBean.nameValueChanges}"/>

                  </h:panelGroup>

       

                   <h:panelGroup>

                      <h:outputText id="template_label" value="Template: " />

                  </h:panelGroup>

       

                   <h:panelGroup>

                      <h:selectOneRadio id="template" value="#{tagNewBean.standardTemplate}" layout="pageDirection" border="0" style="table-layout:auto;">

                          <f:selectItem id="template1" itemLabel="Standard Tag" itemValue="Standard" />

                          <f:selectItem id="template2" itemLabel="DART Agency Tag " itemValue="dart" />

                          <f:selectItem id="template3" itemLabel="Atlas JScript Tag" itemValue="atlas_jscript" />

                          <f:selectItem id="template4" itemLabel="Atlas iFrame Tag" itemValue="atlast_iframe" />

                          <f:selectItem id="template5" itemLabel="PointRoll Tag" itemValue="pointroll" />

                      </h:selectOneRadio>

                  </h:panelGroup>

       

                  <h:panelGroup>

                      <a4j:commandButton id="generate_tag_btn" value="Generate Tag" action="#{tagController.createAction}" reRender="wizardPanelGroup" />

                  </h:panelGroup>

       

                  <h:panelGroup>

                      <a4j:commandButton id="cancel_btn" value="Cancel" action="#{tagController.indexAction}" reRender="wizardPanelGroup" />

                  </h:panelGroup>

          </h:panelGrid>

       

      </h:panelGrid>

       

       

      4. TagNewBean.java

       

      import org.springframework.stereotype.Component;

      import org.springframework.context.annotation.Scope;

      import org.ajax4jsf.model.KeepAlive;

      import java.sql.Timestamp;

      import com.dimestore.vi.domain.Account;

      import javax.faces.event.ValueChangeEvent;

       

      @Scope(value = "request")

      @Component(value = "tagNewBean")

      public class TagNewBean {

       

          private String viewId="/app/project/partial/tagIndex.xhtml";

          private Long id;

          private String name;

          private Account account;

          private String standardTemplate;

       

          public TagNewBean () {

             

          }

       

          public Long getId() {

              return id;

          }

       

          public void setId(Long id) {

              this.id = id;

          }

       

          public String getViewId() {

              return viewId;

          }

       

          public void setViewId(String viewId) {

              this.viewId = viewId;

          }

       

          public String getName() {

              return name;

          }

       

          public void setName(String name) {

              this.name = name;

          }

       

          public String getStandardTemplate() {

              return standardTemplate;

          }

       

          public void setStandardTemplate(String standardTemplate) {

              this.standardTemplate = standardTemplate;

          }

      }

       

       

      5. Controller Class method when click on the Save button

       

      public String createAction() {

              String status = SUCCESS;

       

              TagNew tagNew = new TagNew();

       

              tagNew.setName(tagNewBean.getName()); // getting NULL value over here

              tagNew.setAccount(userSessionBean.getAccount());

       

              if(tagNew != null) {

                 if(tagService.saveTag(tagNew)) {

                      getFacesContext().addMessage(null, new FacesMessage(SEVERITY_INFO, "\"Your new Tag has been created\"", null));

                      //call timer task to create the tagid.js file

                      //initTagScheduler(tagNew);

                  }

                  else {

                      status = FAILURE;

                  }

              }

              else {

                  getFacesContext().addMessage(null, new FacesMessage(SEVERITY_ERROR, "\"**System Error: Unable to create Tag\"", null));

                  status = FAILURE;

              } 

       

               return status;

          }

       

       

      Kindly let me know what I am doing wrong in this code.