How to disable development stage messages? - jsf-2

I like to know if it is posible disable the error messages that appear at the bottom of the page when I have some JSF syntax error:
<ul title="Project Stage[Development]: Unhandled Messages"
id="javax_faces_developmentstage_messages">
<li style="Color: orange">
The button/link/text component needs to have a Form in its ancestry. Please
add <h:form>.
</li>
</ul>
And you can't say "add the form tag".

Remove the <context-param> with name of javax.faces.PROJECT_STAGE from your web.xml, or set its value to Production instead of Development.
See also:
The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within <h:form>

Related

Thymeleaf th tag in blc tag

my problem is following:
in this code
<header>
<h1 th:utext="${BLC_PAGE.pageFields[menu_name]}"></h1>
</header>
<blc:menu resultVar="menuItems" menuName="${BLC_PAGE.pageFields[menu_name]}" />
<ul th:if="${not #lists.isEmpty(menuItems)}">
<li th:each="menuItem : ${menuItems}">
<a th:href="#{${menuItem.url}}" th:class="${menuItemStat.first}? 'home'">
<span th:utext="${menuItem.label}"></span>
</a>
</li>
</ul>
the line <h1 th:utext="${BLC_PAGE.pageFields[menu_name]}"></h1> gets the name of actual menu. I need the menuName in this line <blc:menu resultVar="menuItems" menuName="${BLC_PAGE.pageFields[menu_name]}" /> to do the same thing, but "${BLC_PAGE.pageFields[menu_name]}" is not appropriate, as it is from thymeleaf tags library. Any idea how to get this this value in blc:menu tag?
In order to resolve the Thymeleaf expression ${BLC_PAGE.pageFields[menu_name]}, you will need to wrap it like so: th:attr="menuName=${BLC_PAGE.pageFields[menu_name]}". Because menuName is not a standard HTML attribute, you won't be able to simply add the Thymeleaf namespace to menuName (i.e., th:menuName), and, without the th: namespace, Thymeleaf doesn't know that it needs to resolve any expressions. The Thymeleaf attr attribute allows you to use non-standard HTML attributes with Thymeleaf. For more information on setting attribute values using Thymeleaf you can review their documentation.
Here are links to the Broadleaf and Thymeleaf documentation on Processors and Dialects:
Thymeleaf: http://www.thymeleaf.org/doc/tutorials/2.1/extendingthymeleaf.html#dialects-and-processors

jquery Mobile - Auto Divider

I'm using the jquery Mobile AutoDivider for a web project of mine and it works great in IE8, but for some reason in Chrome it's not generating the headers for me.
My question is: How exactly does the AutoDivider determine what to make a 'divider'? Is is just the first item within your <li></li>?
Here's my basic HTML structure (it's ultimately placed in a ASP.Net Repeater:
<ul data-role="listview" data-autodividers="true">
<li>
<img src="mySource.jpg" alt="" />
<h3>John Doe</h3>
<p><strong>Company Name Here</strong></p>
<p>User Address</p>
<p class="ui-li-aside">
<strong style="display: none;"><!-- This is what seems to make the headers in IE, placing this right here: -->
Last Name of Employee</strong>
</p>
</li>
</ul>
see the docu http://jquerymobile.com/demos/1.2.0/docs/lists/docs-lists.html
Autodividers
A listview can be configured to automatically generate dividers for its items. This is
done by adding a data-autodividers="true" attribute to any listview.
By default, the text used to create dividers is the uppercased first letter of the
item's text. Alternatively you can specify divider text by setting the > autodividersSelector option on the listview programmatically.

Can tab refer to other context element(panel) instead of the tab's context when I use jQuery UI 1.9 Tabs

I want to use jQuery UI 1.9 Tabs like this way:
HTML:
<!-- this is the tab's context -->
<div id="tabs">
<ul id="tabs-ul">
<li id="tabs-email"><a href="#Email" title="Email">Email</li>
<li id="tabs-setting"><a href="#Settings" title="Settings">Setting</li>
</ul>
</div>
<!-- this is the other context -->
<div id="Email">someting</div>
<div id="Settings">someting</div>
JS:
$("#tabs").tabs({});
When I do like blow and click one tab,there will be :
Uncaught Error: jQuery UI Tabs: Mismatching fragment identifier.
What I want is the tab("li#tabs-email"/"li#tabs-setting") can automatic refers to the other div context's panel("div#Email"/"div#Settings").But I can't find the way to change panel context.What am I missing?
I don't think this is possible without significant work. Mainly because the whole "globalPanels" thing is semantically wrong, and is why it's been removed.
The way it works now means that all tab content is implicitly related to the tabs.

p:commandlink inside ui:repeat

In our application we are displaying the menus dynamically. We have the menu object(menuitems in below code) populated with all the menu items (read from an xml). The home page then generates the menus by usinng ui:repeat. Insdie ui:repeat there are p:commandlink.
Below is the code
<h:form id="mainMenu">
<h:panelGroup id="MMPanel" layout="block" styleClass="left_menu">
<ui:repeat var="node" value="#{menuitems.level1menus}">
<p:commandLink immediate="true" styleClass="menu"
action="#{menuitems.onLevel1MenuChange(node.id)}"
update=":pageTitle :menuLevel2 :menuLevel3" title="#{node.name}"
rendered="#{menuitems.selectedLevel1.id!=node.id}" onclick="menuSelect(this)">
<span class="icon icon_#{node.name}"></span>
<span class="text">#{node.name}</span>
</p:commandLink>
<p:commandLink immediate="true" styleClass="menu activelink"
action="#{menuitems.onLevel1MenuChange(node.id)}"
update=":pageTitle :menuLevel2 :menuLevel3" title="#{node.name}"
rendered="#{menuitems.selectedLevel1.id==node.id}" onclick="menuSelect(this)">
<span class="icon icon_#{node.name}"></span>
<span class="text">#{node.name}</span>
</p:commandLink>
</ui:repeat>
</h:panelGroup>
</h:form>
The menuitems bean is at Session level.
There are two diffeent p:commandlink inside ui:repeat. The only difference between the 2 is in the styleclass and rendered attribute. This is done to identify the default menu item when the user logs for the first time and give it an extra css of "activeLink".
The java script called on onclick is given below (in case it is required)
function menuSelect(selectOne){
$(".left_menu>a").removeClass("activelink");
$(selectOne).addClass("activelink");
removeAllChannels();
}
function removeAllChannels(){
$.atmosphere.unsubscribe();
}
The removeAllChannels is to remove primepush autorefresh channels we have.
The issue i am facing is this.
All the links are getting rendered correctly and in Firebug i see all of them have the same html.
But the one which is generated with the extra css "activeLink" (through rendered condition -- menuitems.selectedLevel1.id==node.id) is not working. Nothing happens when i click this default link. All other links work fine.
So when i click on a different link, it takes me to the required page. But when i click back on the menu which was default, nothing happens
I added a Custom phase listener and saw that all the lifecyle stages are called when this link is clicked but the action method is not.
I went through the links this and this but could not figure out the issue.
Please help.
Do tell me if something is not clear
As part of safeguard against tampered/hacked requests, the JSF component's rendered attribute is re-evaluated during processing the form submit. In case of a command link/button, if it evaluates false, then its action won't be queued/invoked. This matches the symptoms you're seeing.
This can in turn happen if the managed bean #{menuitems} is request scoped and/or when the properties behind #{menuitems.level1menus} or #{menuitems.selectedLevel1} are incompatibly changed during the postback request.
Putting the bean in the view scope and ensuring that the getters do not do any business job should fix this problem.
See also:
How to choose the right bean scope?
commandButton/commandLink/ajax action/listener method not invoked or input value not updated - point 5 applies to you

JSF rendered attribute

I have a couple of panel groups, one with "register" and "log in" links, and the other with "log out". When I log in only the "log in" link disappears, the "register" stays rendered, and the "log out" never gets rendered. The #{user.loggedIn}" returns true when the user is logged in. And when refreshing the screen in debug mode I can see that method is being run. Any suggestions for how to get this to work correctly. The code should be explanatory, please let me know if it isn't.
<h:panelGroup rendered="#{!user.loggedIn}">
<li>
<h:outputLink id="loginLink" value="javascript:void(0)" onclick="dlg.show()" title="login" styleClass="loginpanelclass">Log In</h:outputLink>
</li>
<li>
<h:link value="Register" outcome="/registration/register.xhtml" />
</li>
</h:panelGroup>
<h:panelGroup rendered="#{user.loggedIn}">
<li>
<h:commandLink action="#{user.logout()}">Logout</h:commandLink>
</li>
</h:panelGroup>
The elements you want to reference have to be in a naming container if they are not in the same naming container you are referencing them from. For me I launch a login dialog using primefaces when the first link in my question is clicked. Inside the dialog is a form. When that form completes it tells the panels in my question above to render or not by using the p:dialog update attribute. I had to put the panels in my question inside a naming container and then was able to successfully reference them using the ':' notation through the hierarchy.
If anyone is having trouble look for articles on component hierarchies and naming containers in JSF. With the hints given by Daniel in his comments above and the stuff I found looking at hierarchies and naming containers I figured this one out good enough for now. Still a few uncertainties but my code does what I want it to do for now. :) I'm marking the answer Daniel gave in his linked question up by one.

Resources