i'm new to JSF and Primefaces and i have problems with inplace editor. The Editor only works on existing values.
How to get inplace editing on null/empty/blank values ?
Thank you and best regards
Daniel
My code:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title><ui:insert name="title">inplace-demo</ui:insert></title>
</h:head>
<h:body>
<h:form>
<p:dataTable value="#{inplaceController.varList}" var="var">
<p:column headerText="name"><h:outputText value="#{var.name}"/></p:column>
<p:column headerText="val"><p:inplace editor="true" ><p:inputText value="#{var.val}"/></p:inplace></p:column>
</p:dataTable>
</h:form>
</h:body>
</html>
Code: Select all
@ManagedBean(name="inplaceController")
@ViewScoped
public class InplaceController {
private List<Var> varList;
public InplaceController(){
setVarList(new ArrayList<Var>());
getVarList().add(new Var("v1","val1"));
getVarList().add(new Var("v2",""));
getVarList().add(new Var("v3"," "));
getVarList().add(new Var("v4",null));
getVarList().add(new Var("v4","val5"));
}
public List<Var> getVarList() {
return varList;
}
public void setVarList(List<Var> varList) {
this.varList = varList;
}
public class Var{
private String name;
private String val;
public Var(String name, String val){
this.setName(name);
this.setVal(val);
}
public String getVal() {
return val;
}
public void setVal(String val) {
this.val = val;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}