Inplace editor with blanks or empty values

UI Components for JSF
Post Reply
dsg
Posts: 3
Joined: 07 Feb 2012, 14:28

07 Feb 2012, 15:30

Hello,

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;
		}
	}
}
Primefaces 3.1 Mojarra 2.1.0 (FCS 2.1.0-b11) Glassfish 3.1

Marcus Riemer
Posts: 7
Joined: 02 Feb 2012, 10:52

07 Feb 2012, 17:31

What does "only works on existing values" mean? And you might take a look whats said about including versions.

Aside: as you are using a dataTable, have you thought about using its editing feature?
Apache Tomcat 7.0.25 | Apache Myfaces 2.1.5 | Primefaces 3.0
Windows 7 x64 | JDK 1.6.0.23 | Eclipse Indigo Service Release 1

dsg
Posts: 3
Joined: 07 Feb 2012, 14:28

07 Feb 2012, 18:07

Hi Marcus,

i'm using Primefaces-3.1 (same issue with 3.0) , Mojarra 2.1.0 (FCS 2.1.0-b11) on Glassfish 3.1

with "only works with existing values" i mean:
in my example only for v1 and v5 the inplace editor is present.
For v2(""), v3(" ") and v4(null) no inplace-editor is in my resulting web-page.

thanks for your help & best regards

Daniel
Primefaces 3.1 Mojarra 2.1.0 (FCS 2.1.0-b11) Glassfish 3.1

dsg
Posts: 3
Joined: 07 Feb 2012, 14:28

08 Feb 2012, 17:41

Hello,

i've simplified my example-code to demonstrate the issue.

inputText2 is shown, inputText1 is not. It is not possible to insert text into inputText1.
If you click on inputText2 ,remove the text "Value" and click save inputText2 disappaers and it is not possible to insert text to inputText2 again.
I think this is a bug and not the desired behavior.

Code: Select all

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
<h:head>  
</h:head>
<h:body>
		<h:form>
			<h:panelGrid columns="2">			
				<h:outputText value="Insert Text1:"/><p:inplace editor="true" ><p:inputText id="input1" value="  "/></p:inplace>
				<h:outputText value="Insert Text2:"/><p:inplace editor="true" ><p:inputText id="input2" value="Value"/></p:inplace>
			</h:panelGrid>
		</h:form>
</h:body>	
</html>
best regards
Daniel
Primefaces 3.1 Mojarra 2.1.0 (FCS 2.1.0-b11) Glassfish 3.1

keygjones
Posts: 4
Joined: 27 Jan 2012, 13:44

02 Mar 2012, 15:03

Try out the "emptyLabel" attribute.

Parche_
Posts: 32
Joined: 19 Mar 2012, 22:58
Location: Spain - Andalucia - Seville

28 May 2012, 11:43

The solution with "emptyLabel" work fine. In my case with primefaces 3.2 and mojarra 2.1.6, firts I tried to user attribute "label" with username (get database) how value in tag p:inplace and same property in the p:inpuxText in "value" attribute, but I changed the value and always showing value label, only showing real value with I clicked in the input.

With "emptyLabel" I have solved this. In tag p:inplace I place this attribute associated with property in managed bean and in the tag p:inputText I place the property username (database). After only I have to check value change and setting this value.

I think that it will be a good idea to get it to work tag h:outputLabel with tag p:inplace, in this moment I think that it is not possible, Am I right?

Something else, the tag p:calendar is compatible with the p:inplace because in my case , not showing a calendar, the calendar is transformed in p:inputText

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 51 guests