Using p:commandLink twice, second is not working

Mobile UI Kit
Post Reply
MarkusSchulte
Posts: 13
Joined: 28 Jun 2012, 09:52

16 Jul 2012, 09:40

Hi,

i am trying something similar to http://www.primefaces.org/showcase-labs/mobile/news.jsf (http://code.google.com/p/primefaces/sou ... news.xhtml)

I have 3 views, view:main and view:productCategories display a list, view:products is in development.

My problem is, that the second commandLink "<p:commandLink value="${productCategory.id} ${productCategory.name}" update=":products" action="pm:products">" is not working as expected; the first commandLink works fine and brings me from view:main to view:productCategories. When i push the second commandLink to jump from view:productCategories nothing happens.

In FireBug, i see "<pm:view id="products">Produkte[...]" being received after pushing the second CommandLink. Anyway, the setPropertyActionListener on the second CommandLink seems not to be exeucted. ProductCategoryBean::@PostContruct is called when pushing the commandLink, setter is not. First commandLink works with action="pm:products". There seems to be no JavaScript error.

I am using PrimeMobile 0.9.3

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:c="http://java.sun.com/jsp/jstl/core"
	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:pm="http://primefaces.org/mobile">
<h:head>
	<title><ui:insert name="title">Der Taschenbesteller</ui:insert></title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</h:head>
<f:metadata>
	<f:viewParam name="companyId" value="#{companyBean.companyId}" />
	<f:event type="preRenderView" listener="#{companyBean.validateCompany()}" />
</f:metadata>
<f:view renderKitId="PRIMEFACES_MOBILE">
	<pm:page title="Der Taschenbesteller">
		<!-- Renders a company -->
		<pm:view id="main">
			<pm:header title="Der Taschenbestellter - ${companyBean.company.name}">
				<f:facet name="right">
					<p:button value="Settings" icon="gear" href="#settings" />
				</f:facet>
			</pm:header>
			<pm:content>
       		Zeug &uuml;ber die Firma
        	<h3>Menues (${companyBean.getCompanyMenues()})</h3>
				<h:form id="menuesForm">
					<p:dataList value="${companyBean.company.menuesAsList}" var="menu">
						<f:attribute name="filter" value="true" />
						<p:column>
							<p:commandLink value="${menu.id} ${menu.name}" update=":productCategories" action="pm:productCategories">
								<f:setPropertyActionListener value="#{menu}" target="#{menuBean.menu}" />
							</p:commandLink>
						</p:column>
					</p:dataList>
				</h:form>
			</pm:content>
		</pm:view>
		<!--  ProductCategories in a menu -->
		<pm:view id="productCategories">
			<c:if test="#{menuBean.menu.id != null}">
				<pm:header title="Der Taschenbestellter">
					<f:facet name="left">
						<p:button value="Back" icon="back" update=":main" href="#main?reverse=true" />
					</f:facet>
					<f:facet name="right">
						<p:button value="Settings" icon="gear" href="#settings" />
					</f:facet>
				</pm:header>
				<pm:content>
					<h3>Karte: ${menuBean.menu.id} ${menuBean.menu.name}</h3>
					<h:form id="productCategoriesForm">
						<p:dataList value="#{menuBean.menu.productCategoriesAsList}" var="productCategory">
							<f:attribute name="filter" value="true" />
							<p:column>
								<p:commandLink value="${productCategory.id} ${productCategory.name}" update=":products" action="pm:products">
									<f:setPropertyActionListener value="#{productCategory}" target="#{productCategoryBean.productCategory}" />
								</p:commandLink>
							</p:column>
						</p:dataList>
					</h:form>
				</pm:content>
			</c:if>
		</pm:view>
		<!-- Products in a productCategory -->
		<pm:view id="products">Produkte
			<c:if test="#{productCategoryBean.productCategory.id != null}">
				<pm:header title="Der Taschenbestellter">
					<f:facet name="left">
						<p:button value="Back" icon="back" update=":main" href="#main?reverse=true" />
					</f:facet>
					<f:facet name="right">
						<p:button value="Settings" icon="gear" href="#settings" />
					</f:facet>
				</pm:header>
				<pm:content>
					<h3>Produktkategorie: #{productCategoryBean.productCategory}</h3>
				</pm:content>
			</c:if>
		</pm:view>
	</pm:page>
</f:view>
</html>
GlassFish 3.1.2, PrimeFaces 3.4.2

MarkusSchulte
Posts: 13
Joined: 28 Jun 2012, 09:52

16 Jul 2012, 22:14

Hi,

meanwhile i have found a fix. In the seconde view "<pm:view id="productCategories">", i removed the the "<c:if"-statement (i had to replace it at the included datalist by rendered="..." to avoid a NullPointerException).
GlassFish 3.1.2, PrimeFaces 3.4.2

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests