0 Replies Latest reply on May 6, 2008 4:02 PM by Tomas Mika

    jPDL +  validation

    Tomas Mika Newbie

      I am using the jPDL for defining the work flow and also validate the fields in the form using the ajax rerender feature. If I enter invalid data to the field (e.g. leave the form empty for required fiedl) and leave the input, the validation work fine, the message is displayed that I left the field empty (what indicates that the validation is set-up properly).
      But when I send the data to the server by the nodes defined in jPDL, the data are sent allthrough some required fields are emtpy (or e.g. wrong number format is provided).
      I dont want to validate explicitly by using expression in the jPDL, if there is powerful validation framework built in Seam...

      Does anyone know where the problem is? Maybe I missed something really important on inserting the data by using jPDL.

      Here is the code:

      Starting the pageflow:

      <s:button action="#{companyHome.start}" value="#{messages.label_edit}" id="editCompany">
       <f:param name="companyId" value="#{companyHome.instance.id}" />

      pageflow edit company:

      <?xml version="1.0"?>
      <pageflow-definition xmlns="http://jboss.com/products/seam/pageflow"
           xsi:schemaLocation="http://jboss.com/products/seam/pageflow http://jboss.com/products/seam/pageflow-1.2.xsd"
           <start-state name="start">
                <transition name="edit" to="edit" />
                <transition name="remove" to="confirmRemove" />
           <page name="edit" view-id="/portfolio/companyEdit.xhtml">
                <redirect />
                <transition name="save" to="saveCompany" />
                <transition name="cancel" to="complete" />
           <page name="confirmRemove" view-id="/confirm.xhtml">
                <transition name="yes" to="completeDelete" >
                     <action expression="#{companyHome.remove}" />
                <transition name="no" to="complete" />
           <decision name="saveCompany"
                <transition name="true" to="complete">
                     <action expression="#{companyHome.update}" />
                <transition name="false" to="complete">
                     <action expression="#{companyHome.persist}" />
           <page name="complete" view-id="/portfolio/portfolio.xhtml"
                <redirect />
                <end-conversation />
           <page name="completeDelete" view-id="/portfolio/portfolio.xhtml"
                <redirect />
                <end-conversation />

      CompanyHome (Seam framework)

      public class CompanyHome extends EntityHome<Company>
          private static final long serialVersionUID = 9057915693870914547L;
          Integer companyId;
          String action;
          @In(value = "currentUser")
          User currentUser;
          @In(create = true)
          ProductHome productHome;
          @Begin(join = true, pageflow = "editCompany")
          public String start()
              if (action == null || "".equals(action))
                  return CCConstants.OUTCOME_EDIT;
              return action;
          public void setCompanyId(Integer companyId)
              if (companyId != null)
          public Integer getCompanyId()
              return (Integer) getId();
          protected Company createInstance()
              Company company = new Company();
              return company;

      The edit company xhtml:

           <ui:define name="body">
                <h:form id="companyEditForm">
                     <s:decorate template="../layout/editBox.xhtml" id="editBox">
                          <ui:define name="header">
                               <h:outputText value="#{companyHome.managed ? 'messages.label_company_edit': 'messages.label_company_create'}" />
                          <ui:define name="buttons">
                               <s:button id="saveCompany" value="#{companyHome.managed ? messages.label_edit : messages.label_create}" action="save" disabled="#{companyBean.validationFailed}" />
                               <s:button id="cancelCompany" value="#{messages.label_cancel}"
                                    action="cancel" />
                          <s:decorate id="nameDecoration"
                               <ui:define name="label">#{messages.label_name}</ui:define>
                               <h:inputText required="true"
                                    <a:support event="onblur" reRender="nameDecoration" />

      and the Entity bean Company:

      @Table(name = "company")
      public class Company implements Serializable, Idable<Integer>
          private static final long serialVersionUID = 8106268264760054294L;
          @Column(name = "id", unique = true, nullable = false)
          private Integer id;
          private String name;
          @OneToMany(mappedBy = "company", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
          private Collection<Product> products = new ArrayList<Product>(0);
          private User user;
          //getters and setters...