[jboss-user] [JBoss Seam] - h:commandLink behaviour - decode, encode

msznapka do-not-reply at jboss.com
Tue Aug 14 17:29:13 EDT 2007


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!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4074209#4074209

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4074209



More information about the jboss-user mailing list