1 Reply Latest reply on May 30, 2007 8:22 AM by Nicolas Bregenzer

    outputlink order problem

    Nicolas Bregenzer Newbie


      i really don't get the reason for this strange problem:
      first my environment:

      the entity a simple foto with a number attribute

      import java.io.Serializable;
      import javax.persistence.*;
      import org.jboss.seam.annotations.Name;
      public class Photo implements Serializable
       private static final long serialVersionUID = 1L;
       @Id @GeneratedValue
       private long id;
       private String number;
       public long getId() { return id;}
       public void setId(long id) { this.id = id; }
       public String getNumber() { return number; }
       public void setNumber(String number) { this.number = number; }

      the facelet

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
       <h:inputText value="#{photo.number}"/>
       <h:commandButton type="submit" value="Add" action="#{formAction.addItem}"/>
      <h:outputLink value="test.html" rendered="#{myservice.value == true}">Is True</h:outputLink>

      with the corrosponding pages def.

       <page view-id="/test.xhtml">
       <action execute="#{myservice.load}"/>

      and the bean from where the page gets the data

      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.log.Log;
      public class MyServiceBean
       private Log log;
       private boolean value = true;
       public boolean getValue() { return this.value; }
       private Photo photo;
       public Photo getPhoto() { return this.photo; }
       public void load()
       this.photo = new Photo();

      so when the page is loaded the method load is executed and the photo is being outjected. which i then access in my facelet form

      now to the strange part:

      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.log.Log;
      public class FormActionBean implements FormAction
       private Log log;
       Photo photo;
       public void addItem()
       log.info("adding: "+photo.getNumber());
       @Remove @Destroy
       public void Destroy() {}
      public interface FormAction
       public void addItem();
       public void Destroy();

      when i try to submit the form and access the addItem method it won't work.
      an exception is thrown because @In is not non-null
      BUT it works when i put the outputlink above the form.
      i found out its the rendered attribute which messes it up. if i omit it there won't be an error

      i hope someone can help me i tried to post all the necessary files

      thanks in advance

        • 1. Re: outputlink order problem
          Nicolas Bregenzer Newbie

          sadly no answer...

          i guess i have i basic lack of understanding of basic seam principles.

          the scenario is quite simple i have page which displays a single entry (and maybe associated entries) retrieved from a page parameter. basic push/pull approach with the pages.xml and a action.

          up to this point it works but i don't seem to be able to continue from here.
          every time i try to submit a from and run another method it behaves strangly or won't even show an error message.

          this is a simple pattern one would find in a blog. static url to display the blogentry and the possibility to add a comment. (which the example in seam doesn't provide)

          there is an example in seam which provides the basic functionality I'm looking for its th contact list. sadly it tries to demonstrate the simplicity of the application framework.

          can anyone explain to my the basic approach do i have to use a conversation etc.. ???

          thx 4 any help