Reputation: 208
I don't know what I'm doing wrong. I'm using IceFaces and I have simple managed bean:
public class TestingController {
private String name;
public String submit() {
setName("newName");
return null;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
and view:
<ice:inputText value="#{testController.name}" />
<ice:commandButton value="submit" action="#{testController.submit}" />
When I submit the form after first displaying the page, the input is redisplayed with "newName". When I clear the input field and submit the form again, the name is not redisplayed with "newName" as I would expect, but it's still empty.
How is this caused and how can I solve this?
Upvotes: 0
Views: 5323
Reputation: 2057
Try to use actionListener. because if you use action the page send the info and reload the page, but if you use actionListener only fired the event.
<ice:commandButton id="submit" value="SUBMIT" actionListener="#{testController.submit}" />
And in the backing bean:
public class TestingController {
private String name;
public void submit(ActionEvent event) {
setName("newName");
}
Upvotes: 0
Reputation: 15448
Worked for me. After clicking submit, the input box became "newName" regardless of what was in the box previously.
test.jspx
<?xml version="1.0" encoding="UTF-8"?>
<!--
Document : test
Created on : Feb 17, 2009, 2:35:12 PM
Author : drew
-->
<jsp:root xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:ice="http://www.icesoft.com/icefaces/component"
version="2.0">
<f:view>
<ice:form>
<ice:inputText id="inp" value="#{TestController.name}" /> <br/>
<ice:commandButton id="submit" value="SUBMIT" action="#{TestController.submit}" />
</ice:form>
</f:view>
</jsp:root>
TestController.java
public class TestController {
/** Creates a new instance of TestController */
public TestController() {
}
private String name;
public String submit() {
setName("newName");
return null;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
faces-config.xml
<managed-bean>
<managed-bean-name>TestController</managed-bean-name>
<managed-bean-class>com.evi.web.viewdata.TestController</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
Could you give us any more information?
Upvotes: 1