3 Replies Latest reply on Aug 1, 2006 1:50 PM by German de la Cruz

    Question about passing an action Listener

    German de la Cruz Newbie

      Hi people

      I'm very new to seam (Actually, I've using it for 2 weeks). I've read all the documentation I found, I reviewed all the examples.

      Nowadays, I'm making my first complete crud. I must say that I've been using tapestry since 2002, then I think my main problem is trying to solve all the problems in the tapestry way.

      In my application I've using EJB3, Seam and facelets for the view. I've been using a SFSB with Session scope for the actions. I'm using it with session scope because When I go to any action from the table I lost the last search results (Because the default is a temporal conversation). I can't use a long conversation because in a crud it haven't an end This is my code...

      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.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.Unwrap;
      import org.jboss.seam.annotations.datamodel.DataModel;
      import org.jboss.seam.annotations.datamodel.DataModelSelection;
      public class PersonControllerBean implements PersonController {
       private String searchString;
       private PersonService personService;
      // private List<Person> model;
       private Person selected;
       private Person entity;
       public Person getEntity() {
       return entity;
       public void setEntity(Person entity) {
       this.entity = entity;
       public String getSearchString() {
       return searchString;
       public Person getSelected() {
       return selected;
       public void setSearchString(String searchString) {
       this.searchString = searchString;
       public void setSelected(Person selected) {
       this.selected = selected;
       public List<Person> getModel() {
       return (personService.findByNameLike(searchString));
       //return "personCRUD";
       public String select() {
       // setSelected(personService.merge( getSelected()));
       return "personCRUD";
       public String clearSelected() {
       return "personCRUD";
       public void destroy() {

      An this is my xhtml

      <!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"
      <!-- content -->
      <ui:define name="content">
      <div class="section">
       <span class="errors"><h:messages globalOnly="true"/></span>
       <h1>Buscar Padron</h1>
       <h:inputText value="#{personController.searchString}" style="width: 165px;"/>&#160;
       <h:commandButton value="Buscar Padron" action="#{personCRUD}" styleClass="button"/>
      <div class="section">
       <h:outputText value="No se encontraron datos" rendered="#{model != null and model.rowCount==0}"/>
       <h:dataTable value="#{model}" var="e" rendered="#{model.rowCount>0}">
       <f:facet name="header">Razon social</f:facet>
       <f:facet name="header">CUIT/CUIL</f:facet>
       <f:facet name="header">Action</f:facet>
       <s:link value="View" action="#{personController.select}"/>
      <h:panelGroup rendered="#{personController.entity!=null}">
      <div class="section">
       <h1>View Hotel</h1>
      <div class="section">
       <div class="entry">
       <div class="label">CUIT/CUIL</div>
       <div class="output">#{personController.entity.fiscalID}</div>
       <div class="entry">
       <div class="label">Razon Social:</div>
       <div class="output">#{personController.entity.razonSocial}</div>
       <div class="entry">
       <div class="label">Nombre Completo:</div>
       <div class="output">#{personController.entity.completeName}</div>
      <div class="section">
       <h:commandButton value="Ok" action="#{personController.clearSelected}" styleClass="button"/>

      Then, I've some questions...

      1. What do you think of my code?
      2. I can't make a "redirect" with a button from xhtml. When I write a search String I want to redirect to the same page only for reloading the model. How can I make it?
      2. My model (I've put and @DataModel in a getter) is never in the session, isn't it? I mean, by now, I don't want to put in in the session, I want to recalculate in any request. Since it's an internal application the DB isn't a problem. But my session size is a problem.
      3. I want to make a editor component for this entity. I'm thinking in another facelet templeate this a param to call it with the action to execute. How can I make it?

      That's all!