p:codeMirror add validator

Community Driven Extensions Project
Post Reply
Andi
Posts: 46
Joined: 10 May 2012, 18:55

22 Oct 2012, 13:57

Hello,

I'm tried to add to p:codeMirror a validator. Unformtunely it doesn't works. Below a full running example:

facelet.xhtml

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:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pe="http://primefaces.org/ui/extensions">
<f:view>
<h:head><h:title></h:title></h:head>
<h:body>
	<h:form id="form">
		<p:panelGrid columns="2">
			<pe:codeMirror id="codeEditor" value="#{bean.value}" theme="neat"
				mode="text/x-plsql" lineNumbers="true" required="true" validator="#{bean.validate()}">
			</pe:codeMirror>
			<p:message id="codeEditorMessage" for="codeEditor" />
		</p:panelGrid>
		<p:commandButton value="SUBMIT"  type="submit" process="@form" update=":form:codeEditorMessage"/>
	</h:form>
</h:body>
</f:view>
Bean:

Code: Select all

@Named
@RequestScoped
public class Bean implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -8113299336292607251L;

	private String value;
	
	public void validate(FacesContext context, 
								UIComponent toValidate,
								Object value) {
		((UIInput)toValidate).setValid(false);
		FacesMessage message = new FacesMessage("ERROR");
		context.addMessage(toValidate.getClientId(context), message);
	}
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
}
Instead to get the message "ERROR" the p:message shows "/facelet.xhtml @14,91 validator="#{bean.validate()}": Method not found: def.Bean@1e4f95.validate()".
Primefaces 3.4.1 - PE: 0.60 - Mojarra 2.1.7 - JBoss 7.1

tandraschko
PrimeFaces Core Developer
Posts: 3597
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

22 Oct 2012, 14:10

does it work with inputText?
I think your method signature is wrong here.
Always Bet On Prime (+ Extensions)!

Thomas Andraschko
PrimeFaces Developer | PrimeFaces Extensions Founder
Apache OpenWebBeans PMC | Apache DeltaSpike PMC | Apache MyFaces PMC

Personal Blog: http://tandraschko.blogspot.de/

Andi
Posts: 46
Joined: 10 May 2012, 18:55

22 Oct 2012, 14:12

No the method signature is fine.

My failure. A full publish does the job.
Last edited by Andi on 22 Oct 2012, 14:15, edited 1 time in total.
Primefaces 3.4.1 - PE: 0.60 - Mojarra 2.1.7 - JBoss 7.1

tandraschko
PrimeFaces Core Developer
Posts: 3597
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

22 Oct 2012, 14:13

even better :)
Always Bet On Prime (+ Extensions)!

Thomas Andraschko
PrimeFaces Developer | PrimeFaces Extensions Founder
Apache OpenWebBeans PMC | Apache DeltaSpike PMC | Apache MyFaces PMC

Personal Blog: http://tandraschko.blogspot.de/

Andi
Posts: 46
Joined: 10 May 2012, 18:55

22 Oct 2012, 14:24

Thanks zoigl for taking the time.
Primefaces 3.4.1 - PE: 0.60 - Mojarra 2.1.7 - JBoss 7.1

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests