In addition to my question “Creating an“ Edit my element ”page in Java servers using Facelets,“ I would like to address the issue that was provided.
When I press the CommandButton button, the identifier = 100 is deleted, and the page is updated, and this is Before , it even launches the method, correctly, so this means that I do not have the identifier when I click the button.
How do you solve this?
Having this driven bean
public class BeanWithId implements Serializable {
private String id;
private String info;
private void populateInfo() {
info = "Some info from data source for id=" + id;
}
public String getId() { return id; }
public void setId(String id) {
this.id = id;
populateInfo();
}
public String getInfo() { return info; }
public void setInfo(String info) { this.info = info; }
public String save() {
System.out.println("Saving changes to persistence store");
return null;
}
}
And adding
<p><h:commandButton action="#{beanWithId.save}" value="Save" /></p>
On my facelet page. Now I also have the correct information in my faces - config.xml, and when do I access my page using? ID = 100, I get the correct returned item.