tags:

views:

1320

answers:

4

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?

A: 

Hello,

What are you trying to do exactly?

In addition, what is the scope (request, session...) of TestingController?

romaintaz
request scope. I have a page where I can submit values and modify them as well and I still remain on the same page. In myfaces this work. But in icefaces I wasn't able to get it work properly.
michal
+1  A: 

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?

Drew
Have you tried this for the second time? It's the problem when you hit submit for the second time it doesn't work.
michal
I'm not sure what you mean. When you hit it the second time, it makes the input box say "newName" again. No matter what was in the box before, it says "newName" after submit. Is this not what you expect?
Drew
A: 

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");

}
Vudko
A: 

But shouldn't it work even for action?

ext920