jsf - primefaces inputext onblur event not working -



jsf - primefaces inputext onblur event not working -

hello have inputtext on blur event send signal backing bean, bean contains boolean variable determines if input text enabled or not ... can not create work, code:

<ui:composition 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" template="/template.xhtml"> <ui:define name="content"> <h:form id="someform"> <p:growl id="msg" showdetail="true" life="3000"/> <p:panelgrid border="0" id="panel"> <p:row> <p:column width="350"> title </p:column> <p:column colspan="2"> <p:inputtext id="someid" value="#{somebean.somepropertie}"> <p:ajax event="blur" update="anotherinput" listener="#{somebean.onevent}" /> </p:inputtext> </p:column> </p:row> <p:row> <p:column width="350">title 2</p:column> <p:column colspan="2"> <p:inputtext id="anotherinput" converter="touppercaseconverter" value="#{somebean.somepropertie2}" disabled="#{somebean.bdisabled}" /> </p:column> </p:row> </p:panelgrid> </h:form> </ui:define> </ui:composition>

backing bean:

@managedbean @suppresswarnings("serial") public class somebean implements serializable{ private boolean bdisabled; private string somepropertie; private string somepropertie2; public void onevent(){ system.out.println("do something"); this.bdisabled = true; } ... getters , setters of properties , boolean .... }

this main tamplate:

<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets" > <h:head> <title>..:: xxxxx ::..</title> <meta http-equiv="pragma" content="no-cache" /> <link rel="stylesheet" type="text/css" href="#{request.contextpath}/css/default.css"/> <style type="text/css"> .ui-growl{ position:absolute; top:20%; left:50%; z-index:9999; } .ui-widget,.ui-widget .ui-widget { font-family: trebuchet ms; } </style> </h:head> <h:body style="background-color: #e1e1e1;"> <div id="page"> <div id="divheader" style="height: 70px;"> <ui:insert name="header" > <ui:include src="header.xhtml" /> </ui:insert> </div> <div id="divmenu" style="height: 50px;"> <ui:insert name="menu"> <ui:include src="menu.xhtml" /> </ui:insert> </div> <div id="divcontent"> <ui:insert id="content" name="content" > <ui:include src="content.xhtml" /> </ui:insert> </div> </div> </h:body> </html>

the converter:

@facesconverter("touppercaseconverter") public class touppercaseconverter implements converter { @override public string getasstring(facescontext context, uicomponent component, object value) { homecoming (string) value; } @override public object getasobject(facescontext context, uicomponent component, string value) { homecoming (value != null) ? value.touppercase() : null; } }

any thought ???

please help :(

your question not complete, since not provide elements reproduce bug. haven't provided page calls element, neither converter, etc.

jsf's debugger best friend firebug. check javascript errors , enable network tab see each request response body, may contain "silent" error messages.

i'll take risk trying guess problem :-)

here's code, changed run in primefaces 4.

<?xml version="1.0" encoding="utf-8" ?> <!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:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"> <h:head> <title>you need header</title> </h:head> <h:body> <h:form> <ui:include src="index2.xhtml" /> </h:form> </h:body> </html>

and

<ui:composition 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"> <p:growl id="msg" showdetail="true" life="3000" /> <p:panelgrid border="0" id="panel"> <p:row> <p:column width="350"> title </p:column> <p:column colspan="2"> <p:inputtext id="someid" value="#{somebean.somepropertie}"> <p:ajax event="blur" update="anotherinput" listener="#{somebean.onevent}" /> </p:inputtext> </p:column> </p:row> <p:row> <p:column width="350">title 2</p:column> <p:column colspan="2"> <p:inputtext id="anotherinput" value="#{somebean.somepropertie2}" disabled="#{somebean.bdisabled}" /> </p:column> </p:row> </p:panelgrid> </ui:composition>

the managed bean pretty much same

import java.io.serializable; import javax.faces.bean.managedbean; @managedbean @suppresswarnings("serial") public class somebean implements serializable { private boolean bdisabled; private string somepropertie; private string somepropertie2; public void onevent() { system.out.println("do something"); this.bdisabled = true; } public boolean isbdisabled() { homecoming this.bdisabled; } public void setbdisabled(boolean bdisabled) { this.bdisabled = bdisabled; } public string getsomepropertie() { homecoming this.somepropertie; } public void setsomepropertie(string somepropertie) { this.somepropertie = somepropertie; } public string getsomepropertie2() { homecoming this.somepropertie2; } public void setsomepropertie2(string somepropertie2) { this.somepropertie2 = somepropertie2; } }

i've noticed if don't omit head section caller page, seems render , work.

but if forget head section (you must not, see primefaces faq item #2), you'll render page (quite) you'll javascript errors , page won't work. head section talking this

<h:head> <title>you need header</title> </h:head>

this how looks without head section.

with head section, seems work. notice subtle primefaces , feel.

jsf primefaces

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -