0

I've created JSF 1.1 page. In the page I have 2 textboxes and commandbutton. The textboxes are connected to object in the backing bean, and thw object's values are showed there, and the user can edit it as he wants, and when he clicks on the button I want to go to the bean and save the new values in the object. The bean must be request, not session!

<h:inputText value="myBean.PersonName"><\h:inputText>
<h:commandButton action="myBean.saveEditName"><\h:inputText>

backingBean:

public String saveEditName(){
//Go to database and save the new object
}

The problem is, when I click on the button, the bean is refreshed, the objects returns to its previous values, and then the action is invoked. Why is that? How can I perform an action before the submit refreshes the bean? (Without using servlet in javascript).

Thanks!

user1840196
  • 53
  • 1
  • 1
  • 6
  • 1
    Please post the XHTML page and the class for "myBean". – 8bitjunkie Nov 20 '13 at 12:39
  • @7SpecialGems OP's using JSF **1.1** so probably he/she's working with JSP. But the problem is about how to replicate `@ViewScoped` in this old JSF version. When you have 10k rep or more, you could see a deleted answer that explained this in detail and comments where OP just showed no understanding of the solution or adding more problems rather to work in a real world solution. – Luiggi Mendoza Nov 20 '13 at 14:51

1 Answers1

0

Use Explicit Bean Declarations as Given Below:

<managed-bean>
<managed-bean-name>someName</managed-bean-name>
<managed-bean-class>
somePackage.SomeClass
</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>