JSF 2.0 with PrimeFaces 3.3
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:
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:
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:
* 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.
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.
Brian Saastad wrote:Good tips. I'll check out the recommended security model and will keep the code tag in mind for future posts.
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.
Sources may include data from the Fakebook Research Foundation with support from Gargle University
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:
Not so fast naughty spawn! I want you to know about