File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsf table binding attribute help needed

 
Kumar Gaurav
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a table displaying some records.Each record is having info about an user like name, age, role etc. and also having an update button. On clicking update button that particular row should get displayed in form format(there is such page to add user details.) and should be editable as well as not editable in the same page which is being used to add user details.
Please provide some inputs.
 
Anil kumar
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a backing bean which represents the user details
class UserDetails{
private int age;
private String name;
private boolean renderUserForm;
public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
public boolean isRenderUserForm() {
return renderUserForm;
}

public void setRenderUserForm(boolean renderUserForm) {
this.renderUserForm = renderUserForm;
}

}

with in the f:subview place the user form fields

<f:subview rendered="#{user.renderUserForm}">....</f:subview>

write a event listener and access the managed user bean and update fields age,name etc.. also set the renderUserForm boolean value to true

accessing managed beans in a event listener

public Object getManagedBean(String beanName, Object newBean) {

Object bean=null;
if(newBean!=null)
bean = getFacesContext().getExternalContext().getSessionMap().get( beanName );

if(bean == null)
{
getFacesContext().getExternalContext().getSessionMap().put(beanName, newBean);
return newBean;
}
else
{
return bean;
}
}
 
Paul Clapham
Sheriff
Pie
Posts: 20196
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Anil11", please check your private messages about an important administrative matter.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic