MOBILE: redirect to pm:view after a bean action

UI Components for JSF
Post Reply
simo.crombix
Posts: 5
Joined: 05 Aug 2014, 18:32

05 Aug 2014, 18:38

Hi community,

I'm facing a problem while trying to execute
a commandButton action and then redirect to
another pm:view. The bean action is invoked but
the redirect doesn't happen. Hier is an example
of my code:

Code: Select all

<f:view 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" 
            xmlns:pm="http://primefaces.org/mobile" 
            contentType="text/html">

<pm:page id="home">
        <pm:header title="Sample"/>
             <pm:content>
                  <h:form>
                        <p:commandButton action="#{myBean.initItems()}" value="Start"/>
                  </h:form>
            </pm:content>
</pm:page>

<pm:page id="targetPage">
        <pm:header title="Sample"/>
        <pm:content>
            // some content
        </pm:content>
</pm:page>
</f:view>


@ManagedBean
public class MyBean {

  public String initItems(){
       // initialize the items ..
       init();
       return "pm:targetPage?transition=slide";
  }
}

Any suggestions how to fix this issue ?

Thank you in advance.
Crombix.

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

05 Aug 2014, 20:18

Did you do everything that is in the documentation?

And why didn't you post a minimal bean? And why no version info?

simo.crombix
Posts: 5
Joined: 05 Aug 2014, 18:32

06 Aug 2014, 12:06

Hi,
thank you for your prompt reply. I'm using jsf2 with primefaces 5.0 and hier is my code and configuration

managedBean:

Code: Select all

import javax.faces.bean.ManagedBean;
import javax.inject.Inject;

import de.immotec.led.bean.ConfigurationBean;
 
@ManagedBean
public class NavigationView {
	
   @Inject 
   ConfigurationBean configurationBean;
 
    public String getProducts() {
    	configurationBean.initItems();
        return "pm:products?transition=slide";
    }

}
xhtml:

Code: Select all

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pm="http://primefaces.org/mobile">
<f:view renderKitId="PRIMEFACES_MOBILE" />
	<h:head>
		<!-- <script type="text/javascript" src="resources/js/jquery.js"></script>-->
		<style type="text/css">
			.ui-grid-a div {
				padding: 0em 0.5em;
			}			
			
		</style>		
	</h:head>
	<h:body>
			<pm:page id="home">
				<pm:header title="App@Localhost" swatch="b"></pm:header>
					<h:form id="myform">
						<pm:content id="content">									
								<p:tabMenu >
									<p:menuitem value="Products" icon="ui-icon-home" outcome="#{navigationView.getProducts()}" iconPos="top"/>
									<p:menuitem value="Contact" icon="ui-icon-gear" outcome="pm:contact?transition=slide" iconPos="top"/>
								</p:tabMenu>
					</pm:content>
					</h:form>
				<pm:footer title="Footer" swatch="b"></pm:footer>
		</pm:page>

		<pm:page id="products">
			<pm:header title="Produkte" swatch="b">
				<p:button outcome="pm:home?transition=slide" value="Back" icon="ui-icon-arrow-l"
					styleClass="ui-btn-left ui-btn-inline" />
			</pm:header>
			<pm:content>
				<h:form id="productsform">	
					<p:dataGrid var="item" value="#{configurationBean.items}" columns="1">
						<f:facet name="header">
							Produkte
						</f:facet>
						<p:column>
							<p:panel id="prd_panel" styleClass="product_panel">
								<p:commandLink	action="#{configurationBean.setSelectedItemDetails(item.articleNr)}" ajax="false" >
									<p:graphicImage title="#{item.type}" id="pic" value="file/?fileName=#{item.articleNr}_thumb" />
									<div style="height: 3px;" />
										<p>
											<h:outputText value="#{item.articleNr}" />
										</p>
									<p>
										<h:outputText value="#{configurationBean.getShortDescription(item)}" />
									</p>
									<p:outputPanel layout="block" rendered="#{item.newArticle == true}">
										<div id="status" style="position: absolute; top: 0px; left: 0px; text-align: left;">
											<h:graphicImage name="/common/status.png" library="images" />
										</div>											
									</p:outputPanel>
								</p:commandLink>									
							</p:panel>
						</p:column>
					</p:dataGrid>
				</h:form>	
			</pm:content>
		</pm:page>
		<pm:page id="contact">
			<pm:header title="Kontakt" swatch="b">
				<p:button outcome="pm:home?transition=slide" value="Back" icon="ui-icon-arrow-l" styleClass="ui-btn-left ui-btn-inline"/>
			</pm:header>		
			<pm:content>// addresse...</pm:content>		
		</pm:page>

	</h:body>
</html>

Maven Dependencies:

Code: Select all

	<dependency>
			<groupId>org.primefaces</groupId>
			<artifactId>primefaces</artifactId>
			<version>5.0</version>
		</dependency>				
		<dependency>
			<groupId>org.primefaces.extensions</groupId>
			<artifactId>primefaces-extensions</artifactId>
			<version>2.0.0</version>
		</dependency>

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

06 Aug 2014, 18:07

Next time, do not also post in the issue list. It is already bloated with bad issue reports...

And what about this question:
kukeltje wrote:Did you do everything that is in the documentation?
PLEASE... RTFineM... There is documentation for a reasom. it's in the first paragraph of primefaces mobile... the paragraph that is called SETUP

simo.crombix
Posts: 5
Joined: 05 Aug 2014, 18:32

06 Aug 2014, 21:52

Sorry I'm new here. I didn't know that there is a special forum for mobile.
I'm aware of the importance of the documentation. And yes I've read and done everything in it.
Do you see any lacks in my configuration? Have you any suggestions?

Crombix.

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

06 Aug 2014, 22:36

Read 10.1. There is a part in there that you did not mention

simo.crombix
Posts: 5
Joined: 05 Aug 2014, 18:32

07 Aug 2014, 14:14

I missed the configuration in the faces-config you're right thank you. But the target view (in my case "products) is not updated ! the products are set but not read.
I've tried to update the products view by setting update="products" this way:

Code: Select all

     <p:menuitem value="Products" icon="ui-icon-home" update="products" action="#{navigationView.getProducts()}" iconPos="top"/>
But the id "products" were not found even if I see it in the DOM. I get this error: Cannot find component with expression "products".
When I set update=":products" the home view start loading without any redirect.

Thank you for your support.

simo.crombix
Posts: 5
Joined: 05 Aug 2014, 18:32

07 Aug 2014, 17:07

Hi, after setting the navigation-handler

Code: Select all

<application>
		<navigation-handler>
			org.primefaces.mobile.application.MobileNavigationHandler
		</navigation-handler>
	</application>
as you mentioned, the commandButton actions work for me :) The problem accure only with the menuitem actions. Thank you very much for your support.

Crombix.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 39 guests