0 Replies Latest reply on Aug 3, 2006 10:36 PM by German de la Cruz

    What did I make wrong with s:link????

    German de la Cruz Newbie

      Hi people

      I've fighting for a couple of days with a page. In a few words, I've a page that has a datatable, and 2 more sections that are rendered each one depending of the selected action

      This is my page....

      
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <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:s="http://jboss.com/products/seam/taglib"
       template="/WEB-INF/templates/template.xhtml">
      
      <!-- content -->
      
      <ui:define name="content">
      <div class="section">
       <h:form id="searchForm">
       <span class="errors"><h:messages globalOnly="true"/></span>
       <h1>Buscar Padron</h1>
       <fieldset>
       <h:inputText value="#{personController.searchString}" style="width: 165px;"/> 
       <h:commandButton value="Buscar Padron" action="personCRUD" styleClass="button"/>
       </fieldset>
       </h:form>
      </div>
      
      
      <div class="section">
      <h:form id="dataTableForm">
       <h:outputText value="No se encontraron datos" rendered="#{model != null and model.rowCount==0}"/>
       <br/>
       <s:link value="Crear nuevo" action="#{personEditor.createEntity}" buttonClass="button" linkStyle="button"/>
       <br/>
       <h:dataTable value="#{model}" var="e" rendered="#{model.rowCount>0}">
       <h:column>
       <f:facet name="header">Razon social</f:facet>
       #{e.razonSocial}
       </h:column>
       <h:column>
       <f:facet name="header">CUIT/CUIL</f:facet>
       #{e.fiscalID}
       </h:column>
       <h:column>
       <f:facet name="header">Action</f:facet>
      
       <h:commandButton action="#{personEditor.displayEntity}" styleClass="button" value="ver"/>
       <h:commandButton action="#{personEditor.updateEntity}" styleClass="button" value="modificar"/>
       <h:commandButton action="#{personEditor.removeEntity}" styleClass="button" value="eliminar"/>
       </h:column>
       </h:dataTable>
      </h:form>
      </div>
      
      <f:subview rendered="#{personEditor.entity!=null and (personEditor.currentOperation=='DISPLAY' or personEditor.currentOperation=='REMOVE') }">
      <div class="section">
       <h1>View Hotel</h1>
      </div>
      <div class="section">
       <div class="entry">
       <div class="label">CUIT/CUIL</div>
       <div class="output">#{personEditor.entity.fiscalID}</div>
       </div>
       <div class="entry">
       <div class="label">Razon Social:</div>
       <div class="output">#{personEditor.entity.razonSocial}</div>
       </div>
       <div class="entry">
       <div class="label">Nombre Completo:</div>
       <div class="output">#{personEditor.entity.completeName}</div>
       </div>
      </div>
      <h:form id="staticForm">
      <div class="entry">
       <div class="label"><f:verbatim> </f:verbatim></div>
       <div class="input">
       <h:commandButton value="Eliminar" action="#{personEditor.perform}" styleClass="button" rendered="#{personEditor.currentOperation=='REMOVE'}"/> 
       <s:link value="Volver" action="#{personEditor.cleanState}" buttonClass="button" linkStyle="button"/>
       </div>
      </div>
      </h:form>
      </f:subview>
      
      
      <f:subview rendered="#{personEditor.entity!=null and (personEditor.currentOperation=='UPDATE' or personEditor.currentOperation=='CREATE')}">
      <div class="section">
       <h1>View Hotel</h1>
      </div>
      <h:form id="dynamicForm">
      <s:validateAll>
       <div class="entry">
       <div class="label"><h:outputLabel for="fiscalID">CUIT/CUIL:</h:outputLabel></div>
       <div class="input">
       <h:inputText id="fiscalID" value="#{personEditor.entity.fiscalID}" required="true">
      
       </h:inputText>
       <br/><span class="errors"><h:message for="fiscalID"/></span>
       </div>
       </div>
       <div class="entry">
       <div class="label"><h:outputLabel for="razonSocial">Razon Social</h:outputLabel></div>
       <div class="input">
       <h:inputText id="razonSocial" value="#{personEditor.entity.razonSocial}" required="true">
       </h:inputText>
       <br/><span class="errors"><h:message for="razonSocial"/></span>
       </div>
       </div>
       <div class="entry">
       <div class="label"><h:outputLabel for="completeName">Nombre Completo</h:outputLabel></div>
       <div class="input">
       <h:inputText id="completeName" value="#{personEditor.entity.completeName}" required="true">
       </h:inputText>
       <br/><span class="errors"><h:message for="completeName"/></span>
       </div>
       </div>
       <div class="entry">
       <div class="label"><h:outputLabel for="password">Password:</h:outputLabel></div>
       <div class="input">
       <h:inputSecret id="password" value="#{personEditor.entity.password}" required="true"/><br/>
       <span class="errors"><h:message for="password"/></span>
       </div>
       </div>
      </s:validateAll>
      <div class="entry errors"><h:messages globalOnly="true"/></div>
      <div class="entry">
       <div class="label"><f:verbatim> </f:verbatim></div>
       <div class="input">
       <h:commandButton value="Modificar" action="#{personEditor.perform}" styleClass="button" rendered="#{personEditor.currentOperation=='UPDATE'}"/>
       <h:commandButton value="Crear" action="#{personEditor.perform}" styleClass="button" rendered="#{personEditor.currentOperation=='CREATE'}"/>
        
       <s:link value="Volver" action="#{personEditor.cleanState}" buttonClass="button" linkStyle="button"/>
       </div>
      </div>
      </h:form>
      </f:subview>
      
      </ui:define>
      </ui:composition>
      


      As you can see, I've this in my datatable...

       <h:column>
       <f:facet name="header">Action</f:facet>
      
       <h:commandButton action="#{personEditor.displayEntity}" styleClass="button" value="ver"/>
       <h:commandButton action="#{personEditor.updateEntity}" styleClass="button" value="modificar"/>
       <h:commandButton action="#{personEditor.removeEntity}" styleClass="button" value="eliminar"/>
       </h:column>
      


      If I use a commandButton, everything works like a charm, but, If I change it with...

       <h:column>
       <f:facet name="header">Action</f:facet>
       [<s:link value="ver" action="#{personEditor.displayEntity}"/>]
       [<s:link value="modificar" action="#{personEditor.updateEntity}"/>]
       [<s:link value="eliminar" action="#{personEditor.removeEntity}"/>]
       </h:column>
      
      


      My dataTableSelection in my PersonFinder never loads (It's null always) then, I can't edit, view or update.

      I don't know If you need any more information, I think it's a problem in my page! Anyway, I'll show you my actions anyway

      package manchot.actions;
      
      import java.util.List;
      
      import javax.ejb.EJB;
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      
      import manchot.model.Person;
      import manchot.services.PersonService;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.Factory;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.datamodel.DataModel;
      import org.jboss.seam.annotations.datamodel.DataModelSelection;
      
      @Name("personFinder")
      @Stateful
      @Scope(ScopeType.EVENT)
      @LoggedIn
      public class PersonFinderBean implements PersonFinder {
      
       @EJB
       private PersonService personService;
      
       @DataModel(scope=ScopeType.PAGE)
       private List<Person> model;
      
       @DataModelSelection
       private Person selected;
      
       @In(create=true)
       private PersonController personController;
      
       @Factory("model")
       public void findModel() {
       model = (personService.findByNameLike(personController.getSearchString()));
       }
      
       public void refresh(){
       findModel();
       }
      
       @Destroy
       @Remove
       public void destroy() {
       }
      
       public Person getSelected() {
       return selected;
       }
      }
      


      package manchot.actions;
      
      import javax.ejb.EJB;
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.ejb.TransactionAttribute;
      import javax.ejb.TransactionAttributeType;
      
      import manchot.actions.util.Operations;
      import manchot.model.Person;
      import manchot.services.PersonService;
      
      import org.hibernate.validator.Valid;
      import org.jboss.seam.annotations.Begin;
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.End;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      
      @Name("personEditor")
      @Stateful
      @LoggedIn
      public class PersonEditorBean implements PersonEditor {
      
       private Operations currentOperation;
      
       @EJB
       private PersonService personService;
      
       @In(create=true)
       private PersonFinder personFinder;
      
       @Valid
       private Person person;
      
      
       public Operations getCurrentOperation() {
       return currentOperation;
       }
      
       public void setCurrentOperation(Operations currentOperation) {
       this.currentOperation = currentOperation;
       }
      
       @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
       public Person getEntity() {
       return person;
       }
      
       public void setEntity(Person entity) {
       this.person = entity;
       }
       @Begin(join=true)
       public String displayEntity() {
       setEntity(personFinder.getSelected());
       currentOperation=Operations.DISPLAY;
       return "personCRUD";
       }
       @Begin(join=true)
       public String updateEntity() {
       setEntity(personFinder.getSelected());
       currentOperation=Operations.UPDATE;
       return "personCRUD";
       }
       @Begin(join=true)
       public String createEntity() {
       setEntity(new Person());
       currentOperation=Operations.CREATE;
       return "personCRUD";
       }
      
       @Begin(join=true)
       public String removeEntity() {
       setEntity(personFinder.getSelected());
       currentOperation=Operations.REMOVE;
       return "personCRUD";
       }
       @End
       public String cleanState() {
       setEntity(null);
       setCurrentOperation(null);
       return "personCRUD";
       }
       @End
       public String perform() {
       if(currentOperation==Operations.REMOVE){
       personService.remove(person);
       }else{
       personService.save(person);
       }
       return cleanState();
       }
      
       @Destroy
       @Remove
       public void destroy() {
       }
      }
      
      


      package manchot.actions;
      
      import javax.ejb.Remove;
      
      @Name("personController")
      @Stateful
      @Scope(ScopeType.SESSION)
      @LoggedIn
      public class PersonControllerBean implements PersonController {
      
       private String searchString="";
      
       public String getSearchString() {
       return searchString;
       }
      
       public void setSearchString(String searchString) {
       this.searchString = searchString;
       }
      
       @Destroy
       @Remove
       public void destroy() {
       }
      }
      



      Thanks!!!