• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setter not called on submit  RSS feed

 
Dowell Griffin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to JSF. I created a page based on some examples I see from the JBoss Seam examples but my problem is not Seam related (I think).

It is very simple. Enter a value into an h:inputText field, click a button to call an action method on an SLSB. The problem is the setter for the text field (setTestVal) is not being called. It is my understanding it should be called to load the text typed into the page into the testVal property of the SLSB before the action method is called. I can build the examples I have and they work! I noticed the example used a SFSB. I tried making mine a SFSB but nothing changed. I must have missed something or misunderstand how this works (again, new stuff to me)

Environment: JBoss AS 4.0.5, Seam 1.2.1.GA, JSF?? whatever comes with this JBoss version (I think myfaces 1.1.4).

From Page:

<h:form>
<h:inputText value="#{Tester.testVal}"/>
<s:button title="Submit" action="#{Tester.post}" />
</h:form>

From SLSB:

@Name("Tester") // seam annotation, avoids XML definition
public @Stateless class ActionTestBean implements ActionTest {

private String testVal;

public String getTestVal() {
return testVal;
}

// SHOULDN'T THIS SETTER BE CALLED BEFORE THE POST METHOD WHEN THE BUTTON IS // CLICKED to load what was entered into the page ???
public void setTestVal(String testVal) {
this.testVal = testVal;
}

public void post()
{

String tmp = testVal;

}

The action method is called as I expect. There are no errors of any kind that I see or can find in the logs.

HELP!
 
Dowell Griffin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SOLVED!

It turns out the s:button (seam component) does not submit the form! From Seam manual:

A button that supports invocation of an action with control over conversation
propagation. Does not submit the form.

I changed it to h:commandButton and it works!
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your solution.

I'm also testing Seam because I want to implement this framework for a customer of mine and will make sure that I don't make the same mistake.

Good luck with your testing.
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy "lpmon",

That's nice to see that you solved the issue. Here are a couple of suggestions.

(1) please adjust your display name according to the ranch's naming policy. You can please go through the Name Page and easily update your name by editing your profile.

(2) Please use the Code Tags for pasting the java code and output so that it will help the code look clean.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!