5 Replies Latest reply on Aug 15, 2007 8:13 AM by Martin Sznapka

    h:commandLink behaviour - decode, encode

    Martin Sznapka Newbie

      Hi,
      I have very simple Seam application:
      numberGuess.jspx:

      <h:form>
       <h:inputText value="#{numberGuess.input}"/>
       <h:commandLink action="#{numberGuess.doSomething}" value="submit"/>
      </h:form>
      

      NumberGuess.java
      @Name("numberGuess")
      @Scope(ScopeType.EVENT)
      public class NumberGuess implements Serializable {
      
       private String input;
      
       public String getInput() {
       System.out.println("getInput()");
       return input;
       }
      
       public void setInput(String input) {
       System.out.println("setInput()");
       this.input = input;
       }
      
       public String doSomething() {
       System.out.println("doSomething()");
       return null;
       }
      
       @Create
       public void begin() {
       System.out.println("created");
       randomNumber = new Random().nextInt(100);guessCount = 0;biggest = 100;smallest = 1;
       }
      
       @Destroy
       public void end() {
       System.out.println("destroyed");
       System.out.println("----------");
       }
      
      ...
      


      PROBLEM:
      results are:
       created
       getInput() <--
       setInput()
       doSomething()
       getInput()
       destroyed
       ----------
      


      which is strange for me, because I expected result without first getInput, which is called in encode phase of the component. the next getInput is called in decode phase

      it is right behaviour? because i have application where are lot of inputs generated with ui:repeat and data for inputs are loaded from database TWICE (two getXXX())

      are there any solution to have behaviour like this?:
       created
       setInput()
       doSomething()
       getInput()
       destroyed
       ----------
      


      Thanks!