BUG (3.0.M4): Passing more than two parameters.

UI Components for JSF
Post Reply
marceltessarini
Posts: 5
Joined: 01 Nov 2011, 19:10

01 Nov 2011, 19:35

I was using PrimeFaces 3.0.M3 and I updated my project for 3.0.M4 to evaluate it, but there is a bug when I want send more than one parameter in p:commandButton: the parameter carId isn't sent. The code and technologies used are below.

senderParam.xhtml

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:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>Sender Param</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</h:head>
<h:body>
	<h:form id="senderParamForm" prependId="false">
		<p:commandButton value="Send param" action="#{receiverParam.goToReceiverParam}" ajax="false">
			<f:param name="carId" value="-10" />
			<f:param name="otherParam" value="otherParam" />
		</p:commandButton>
	</h:form>
</h:body>
</html>
receiverParam.xhtml

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:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>Car Form</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</h:head>
<h:body>
	<h:form id="carForm" prependId="false">
		Passed Param is: <h:outputText value="#{receiverParam.carId}" />
	</h:form>
</h:body>
</html>
The backing bean ReceiverParam.java

Code: Select all


import javax.annotation.PostConstruct;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component("receiverParam")
@Scope("request")
public class ReceiverParam {

	private String carId = "";
	
	
	@PostConstruct
	public void init() {
		carId = getParameter("carId");
		if (carId == null || "".equals(carId)) {
			carId = "No param";
		}
	}
	public String goToReceiverParam() {
		return "/receiverParam.html";
	}
	public String getCarId() {
		return carId;
	}
	private String getParameter(final String name) {
		return getRequest().getParameter(name);
	}
	private HttpServletRequest getRequest() {
		return (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
	}
}
If remove "<f:param name="otherParam" value="otherParam" />" from senderParam.xhtml, all works fine!


JSF 2.0.3 Mojarra
Spring 3.0.5.RELEASE
Jetty 7.3.0.v20110203

spauny
Posts: 75
Joined: 10 Oct 2011, 16:42

02 Nov 2011, 09:04

Yes, I think this is a bug...You can create an issue.
For your problem, another way would be to use setters and getters with predefined values:

Code: Select all

<p:commandButton value="Send param" action="#{receiverParam.goToReceiverParam}" ajax="false">
                        <f:param name="carId" value="-#{receiverParam.carId}" />
                        <f:param name="otherParam" value="#{receiverParam.otherParam}" />
                    </p:commandButton>

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 49 guests