Couldn't override update method
shtv Dec 7, 2010 6:38 AMHello!
I have some problems with EntityHome. I do the same work as one in reference (this chapter: http://docs.jboss.org/seam/2.2.1.CR2/reference/en-US/html/framework.html ). My method works but Hibernate always updates given record. Even if my update method is blank. Below my source:
@Name("stageHome")
public class StageHome extends EntityHome<StagesSchedule> {
     static final long serialVersionUID = 1L;
     @Factory("stage2")
     public StagesSchedule initStagesSchedule() {
          return getInstance();
     }
     protected StagesSchedule createInstance() {
          return new StagesSchedule();
     }
     /*
     protected String getUpdatedMessageKey() {
          return "stage_updated";
     }
     */
     public String update() {
          return "";
          /*
          try {
               validate();
               return "";
//               return super.update();
          } catch(ValidatorException e){
               getFacesMessages().add(e.getFacesMessage());
               return null;
          }
          */
     }
     public String persist() {
          return "";
     };
     public String remove() {
          return "";
     };
     /*
     private void validate() {
          StagesSchedule schedule = getInstance();
          if(schedule.getBegin().after(schedule.getEnd()))
               throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,"Validation failed!",null));
     }
     */
}     <ui:define name="body">
          <h:dataTable value="#{stages}" var="_stage" rendered="#{not empty stages}">
               <h:column>
                    <f:facet name="header">
                         <h:outputText value="Name"/>
                    </f:facet>
                    <h:outputText value="#{_stage.name}"/>
               </h:column>
               <h:column>
                    <f:facet name="header">
                         <h:outputText value="Begin date"/>
                    </f:facet>
                    <h:outputText id="begindate" datePattern="dd-MM-yyyy" value="#{_stage.begin}">
                         <s:convertDateTime pattern="dd-MM-yyyy"/>
                    </h:outputText>
               </h:column>
               <h:column>
                    <f:facet name="header">
                         <h:outputText value="End date"/>
                    </f:facet>
                    <h:outputText id="enddate" datePattern="dd-MM-yyyy" value="#{_stage.end}">
                         <s:convertDateTime pattern="dd-MM-yyyy"/>
                    </h:outputText>
               </h:column>
               <h:column>
                    <f:facet name="header">
                         <h:outputText value="Action"/>
                    </f:facet>
                    <s:link value="Edit">
                         <f:param name="stageId" value="#{_stage.id}"/>
                    </s:link>
               </h:column>
          </h:dataTable>
          <h:form rendered="#{stageHome.managed}">
               <h:inputText value="#{stage2.name}"/>
               <rich:calendar id="begin1" datePattern="dd-MM-yyyy" value="#{stage2.begin}"/>
               <rich:calendar id="end1" datePattern="dd-MM-yyyy" value="#{stage2.end}"/>
               <h:commandButton value="Update" action="#{stageHome.update}"/>
          </h:form>
     </ui:define><?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://jboss.com/products/seam/pages"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.2.xsd">
          <param name="stageId" value="#{stageHome.id}" converterId="javax.faces.Integer"/>
</page>Thanks for reply!
 
    