• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Activating page in another panel -- almost working but puzzled

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, environment details:

JSF 2.0 with PrimeFaces 3.3
Glassfish 3.1
Mojarra 2.1.6
Firefox 13.1 (but I've tried this in Chrome, Safari, IE and the behavior is the same)

I'm implementing a very common use case -- accordion menu on the right, clicking buttons loads a page in a center panel. To summarize the problem, if the user logs in and clicks a menu button, the button's action listener stores the target page in a bean, then updates the center section which extracts the url from the bean and loads the page. This at first appears to work, but there is a <p:selectOneMenu> on the target page that shows a list of users; selecting an entry from the list updates the user info on the screen -- simple. However, when I make a selection from the dropdown it does not dismiss. It just displays my selection in the input area of the component, but the menu itself does not dismiss and nothing in the attached bean (listeners, converter) fires. Clicking the selection again in the dropdown causes the menu to disappear, but still no action is taken.

Here's the confusing part -- I've obviously missed some detail: The login page is index.xhtml. Upon successful login, it navigates to main_menu.xhtml which references a facelet template that contains the Primefaces layout. main_menu.xhtml inserts the accordion into the west section of the layout. Under normal conditions, the browser URL continues to refer to index.xhtml; no problem with that, but if after I've initiated the session I type main_menu.xhtml directly into the browser url, the whole thing works exactly as it should. I can even log out and log back in and it will continue to work, all the time showing main_menu.xhtml in the browser url.

Here are the details (fwiw, forms are all defined as <h:form> -- I believe I've eliminated the easy setup stuff that could be derailing me):

Here's the submit button definition in index.xhtml:

<td colspan="2"><p:commandButton id="submit_login" value="#{msg.login_button}" action="#{sessionInfo.login}" update="focus" ajax="false"/></td>

The login falls into the default navigation rule here:

<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>CALLCENTER</from-outcome>
<to-view-id>/callcenter.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>FAILED</from-outcome>
<to-view-id>/index.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<to-view-id>/main_menu.xhtml</to-view-id>
</navigation-case>
</navigation-rule>

Salient excerpts from my facelet template:

<h:body>
<p:layout fullPage="true">
.
.
.
<p:layoutUnit id="main_lu_center" position="center">
<p:outputPanel id="main_panel_center">
<ui:insert name="content">
<ui:include src="#{nav.getPage('main_panel_center','/dashboard.xhtml')}" />
</ui:insert>
</p:outputPanel>
</p:layoutUnit>

The getPage method just looks up the page to display based on the first param. The second param is just a default in case the requested mapping is not found.
Here are the pieces of main_menu.xhtml where it references the template and the commandButton that posts the page to display in the center section and updates the section:

<ui:composition template="/templates/master-layout.xhtml">
.
.
.
<p:commandButton value="#{msg.user_modify_tab}"
actionListener="#{nav.setPage('main_panel_center','/user/modify_user.xhtml')}"
update=":main_panel_center"
/>

The guts of modify_user.xhtml. I don't call user_details directly because it handles both the add and modify user scenarios, morphing slightly based on the 'mode' param:

<ui:composition>

<h:form id="modify_user_form">
<ui:include src="/user/user_details.xhtml" >
<ui:param name="mode" value="modify" />
</ui:include>
</h:form>

</ui:composition>

And finally, the select menu from user_details. Pardon all the noise, but this particular component is only accessible to certain users, plus is not rendered at all when adding a user:

<h:outputLabel value="#{msg.user_username}" />
<p:selectOneMenu id="username_menu" value="#{user.selectedUser}"
disabled="#{!sessionInfo.hasAccess('UPDATE','USER_MODIFY','USER_NAME')}"
valueChangeListener="#{user.enableLoad}"
rendered="#{mode == 'modify'}" >
<f:converter converterId="userConverter" />
<f:selectItems value="#{user.userList}" />
<f:ajax event="change"
render="email email_confirm first_name last_name passwd passwd_confirm authorization" />
</p:selectOneMenu>

So, what am I missing? Again, once I log in, this all works perfectly IF I manually enter main_menu.xhtml into the browser, but not if I work off of the basic login navigation. The last tidbit of information is that if I have the FF error console open, when this fails, I get 'Mojarra is not defined' followed by this url: http://localhost:9090/reclient/faces/javax.faces.resource/jquery/jquery.js?ln=primefaces. Based on a suggestion in another post, I pasted that URL into my browser and got the jquery.js page. Here's the header at top of the listing:

/*
* jQuery JavaScript Library v1.7.2
* http://jquery.com/
*
* Copyright 2011, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
* Copyright 2011, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
*
* Date: Wed Mar 21 12:46:34 2012 -0700
*/

The 'Mojarra ...' error does not show up when I go directly to main_menu.xhtml.

I'm at a loss. It appears to be losing its idea of where it is, but I can't for the life of me sort it out. I'm very new to the JSF world, so I'm probably missing something simple, but hours of forum searches seem to get close, but still no luck.

Thanks.

 
Brian Saastad
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Almost forgot -- here's my web.xml so you can see my servlet mappings:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name>reclient</display-name>
<welcome-file-list>
<welcome-file>/faces/index.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>le-frog</param-value>
</context-param>
<context-param>
<param-name>facelets.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
</web-app>
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm going to be almost totally useless here - Getting up to date on PrimeFaces is one of those things on my "to-do" list that never gets done, but I will make 2 observations for what they are worth:

1. (and you'll see me pound this drum almost daily): User-designed login systems are - in my many years of experience - one and all, insecure and most commonly, grossly insecure to the point where it's a no-brainer for non-technical people to break them in a matter of minutes. J2EE includes a built-in security system that was developed and vetted by people whose full-time job is security systems, In 99 cases out of 100, it's what I recommend using over DIY stuff. Aside from everything else, it integrates directly into the JEE API, which DIY systems don't.

2. You can make your samples easier to read thanks to a useful feature of our message editor that's explained here: https://coderanch.com/how-to/java/UseCodeTags
 
Brian Saastad
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good tips. I'll check out the recommended security model and will keep the code tag in mind for future posts.

Thanks.
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Brian Saastad wrote:Good tips. I'll check out the recommended security model and will keep the code tag in mind for future posts.

Thanks.



Actually, you should be able to go back and edit your first post and add the tags manually. The "Preview" button can help. In cases where bit of code had displayed as "smilies", some cleanup is in order, though.
 
Brian Saastad
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In case anyone else runs across this, I finally got this to work as desired. Simple, now that I know the answer. Just added the ajax render line into the command button and left everything else the same. Turns out both the update AND the render are needed for this to work:

 
reply
    Bookmark Topic Watch Topic
  • New Topic