0

When a commandLink is clicked, a new row should be added in the DataTable. The data entered in the previous row is being cleared when the link is clicked.

I added <f:ajax event="click" render="@form" listener="bean.method"/> for <h:commandLink>. What is the solution for this problem.

user679526
  • 845
  • 4
  • 16
  • 39

1 Answers1

1

The bean is apparently request scoped and is apparently not saving the data of the previous row so that it can be preloaded in the bean's constructor of the next request.

Putting the bean in a bit broader scope should fix this problem. I'd recommend putting the bean in the view scope. This way the bean will live as long as you're returning void or null in action methods.

@ManagedBean
@ViewScoped
public class Bean implements Serializable {

    // ...

}

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I referred to the example in link. I implemented in the same way. The new row is being added on top of the populated row. But the requirement is to add the new empty row below the populated row. . If I use outputText to display data as discussed in the example, the new row is added below. But I need to have inputText only because the row should be editable at all times. – user679526 Jul 13 '11 at 03:38