blur does not work with p:ajax

UI Components for JSF
Post Reply
jbmeyer
Posts: 18
Joined: 25 Jun 2010, 11:30

21 Jul 2010, 18:18

Hello everyone,

I have a problem I really don't understand.
I'm using the last version of primefaces ( downloaded today ), JSF2.0 with Mojarra-2.0.2 , Glassfish 3.01.

I used the code I found in another topic
http://primefaces.prime.com.tr/forum/vi ... t=p%3Aajax

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.prime.com.tr/ui">

  <h:head>
  </h:head>

  <h:body>
    <h:form>
      <h:outputLabel value="Zip:"/>
      <p:inputMask id="zip" mask="99999-999" value="#{dataBean.zip}" required="true" requiredMessage="Required field">
        <p:ajax event="blur" update="message" actionListener="#{dataBean.onZipBlur}" />
      </p:inputMask>
      <h:message for="zip" />
      <br />

      <h:outputLabel value="Message:"/>
      <h:outputText id="message" value="#{dataBean.message}" />
      <br />

      <h:commandButton value="Do It" />
    </h:form>
  </h:body>

</html>
with the bean

Code: Select all

package controller;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import javax.faces.event.ActionEvent;

@ManagedBean
@ViewScoped
public class DataBean implements Serializable {
    private String _zip;
    private String _message;

    public DataBean() {
    }

    public String getZip() {
        return _zip;
    }

    public void setZip(String zip) {
        _zip = zip;
    }

    public String getMessage() {
        return _message;
    }

    public void setMessage(String message) {
        _message = message;
    }

    public void onZipBlur(ActionEvent ev) {
        setMessage("Zip set to: " + " - " + getZip());
    }
}
This example works perfectly but if I use a regular <h:inputText> instead of <p:inputMask> as it is in the showcase

Code: Select all

<h:form>
			
	<p:panel header="Ajaxify">
		<h:panelGrid columns="3" cellpadding="5">
			<h:outputText value="KeyUp: " />
			<h:inputText id="firstname" value="#{pprBean.firstname}">
				<p:ajax event="keyup" update="out1" />
			</h:inputText>
			<h:outputText id="out1" value="#{pprBean.firstname}" />
			
			<h:outputText value="Blur: " />
			<h:inputText id="surname" value="#{pprBean.surname}">
				<p:ajax event="blur" update="out2" />
			</h:inputText>
			<h:outputText id="out2" value="#{pprBean.surname}" />
		</h:panelGrid>
	</p:panel>
	
	<p:ajaxStatus style="width:16px;height:16px;">
		<f:facet name="start">
			<h:graphicImage value="../design/ajaxloading.gif" />
		</f:facet>
		
		<f:facet name="complete">
			<h:outputText value="" />
		</f:facet>
	</p:ajaxStatus>
				
</h:form>
The onblur never work. Even if I don't have any actionListener and an update on "message", the h:outputText is never refreshed.

I'm completely blocked on that.
Do you have any idea ?

Thanks

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

21 Jul 2010, 19:51

Do you have;

Code: Select all

<context-param>
   <param-name>com.sun.faces.allowTextChildren</param-name>
   <param-value>true</param-value>
</context-param>
in your web.xml?

jbmeyer
Posts: 18
Joined: 25 Jun 2010, 11:30

23 Jul 2010, 09:20

Thank you very much, it works now.
Is it written as a note in the Primefaces documentation ? It could be a good idea for other people with the same problem.

Thank you

User avatar
michiel
Posts: 240
Joined: 07 Jun 2010, 09:12
Location: Belgium

23 Jul 2010, 09:26

last user guide (18/07/2010)
on the bottom of page 13
;)
JSF-2.0, mojarra-2.0.2-FCS and PrimeFaces-2.1 on GlassFish v3.0.1 (build 22)

jbmeyer
Posts: 18
Joined: 25 Jun 2010, 11:30

23 Jul 2010, 09:57

Thank you :) as we say in software engineering : RTFM :)
That's my fault ;)

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

23 Jul 2010, 10:30

Good to hear it works now! In 2.2. release we'll remove the need for this context-param.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests