Seam Faces InputField injection not working
bjoernp Sep 21, 2012 8:19 AMI have already posted this question on Stackoverflow, but I fugure posting it here might reach a more appropriate audience. I am not sure if this is the appropriate forum for this, so please corret me if I posted in the wrong place. I am using Seam Faces 3.1.0.FINAL on JBossAS 7.1.1.FINAL, and I cannot get injection of input-fields to work.
I am using this validator:
@FacesValidator("myValidator")
public class MyValidator implements Validator {
@Inject
@InputField
private String foo;
@Inject
@InputField private String bar;
public void validate(FacesContext arg0, UIComponent arg1, Object arg2)
throws ValidatorException {
System.out.println("**********************");
System.out.println("Foo : " + foo);
System.out.println("Bar : " + bar);
System.out.println("**********************");
}
}
with this page (showing only the body for brevity):
<h:body>
<h:form>
<h:inputText id="foo" value="#{bean.foo}" />
<h:inputText id="bar" value="#{bean.bar}" />
<h:commandButton value="Submit" />
<s:validateForm validatorId="myValidator" />
</h:form>
</h:body>
The validator is invoked correctly, but the fields are always null
. I have declared the following dependencies in my pom.xml
:
<dependencies>
<dependency>
<groupId>org.jboss.seam.faces</groupId>
<artifactId>seam-faces-api</artifactId>
<version>3.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.seam.faces</groupId>
<artifactId>seam-faces</artifactId>
<version>3.1.0.Final</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.seam.international</groupId>
<artifactId>seam-international</artifactId>
<version>3.1.0.Final</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
I have no special setup in either my web.xml
or faces-config.xml
(in fact, I don't have a faces-config.xml
). Is there any additional configuration required to make injection work? Or, as an alternative, is there a way to use <s:validateForm>
without injection?
P.S.: I have attached my sample project. The pom.xml references the properties containerId and containerHome, which I have set to jboss71x and the path to my JBoss installation (these are used by cargo to deploy the application). Once you have configured (or replaced) these, you should be able to build and run the project using the command mvn install cargo:run. The application should then be available under http://localhost:8080/seam-test/main.xhtml. Once you submit the form, the validator is correctly triggered, but in the command-line output (on the console in which you invoked maven) you will see that the values of the fields are printed as null.
-
seam-test.zip 3.2 KB