-
30. Re: How to build rich:dropDownMenu dynamically
mores Nov 15, 2007 4:47 PM (in response to tomarenz)"mores" wrote:
"Dsleeper" wrote:
Can anybody from the richfaces team show a code example of how this should be done?
Ie a complete createMethodExpression code example?
I finally got this to work:
It works fine with JSF 1.1 (myfaces), but when I try to upgrade to 1.2 ( jsf-ri ) I get this error:javax.el.PropertyNotWritableException: /WEB-INF/layout/header.xhtml @24,56 binding="#{webmenu.myBar}": Property 'myBar' is not writable on type: WebMenu
-
31. Re: How to build rich:dropDownMenu dynamically
vibhavgargcgi Dec 14, 2007 3:59 PM (in response to tomarenz)Instead of using the actionListener on the menu item, I would like to programtically add this fragment
<h:commandLink> <f:param></f:param> </h:commandLink>
using the component classes for these tags. Does anybody know how to do this?
Thanks
Vibhav -
32. Re: How to build rich:dropDownMenu dynamically
littleprince Feb 27, 2008 4:50 AM (in response to tomarenz)Hi, after i read the posting here, i got the idea how to create dynamic sub menu. What about the main one? i dont know if i misunderstand the idea here.
i will take the browser menu as example.
Let say i got "File", "Edit", "View" menu.
the example only able to dynamically create the item under the "File".
If i wan to add a menu after "View", let say is "Favorites", how to i create it programmically? -
33. Re: How to build rich:dropDownMenu dynamically
mores Feb 27, 2008 10:20 AM (in response to tomarenz)The example has:
public org.richfaces.component.html.HtmlDropDownMenu getMyMenu()
If you want to build the whole thing then you need to start like this:public org.richfaces.component.html.HtmlToolBar getMyBar() { org.richfaces.component.html.HtmlToolBar bar = new org.richfaces.component.html.HtmlToolBar(); org.richfaces.component.html.HtmlDropDownMenu ddm = new org.richfaces.component.html.HtmlDropDownMenu(); /* Add you sub-menu here */ bar.getChildren().add( ddm ); return( bar ); }
-
34. Re: How to build rich:dropDownMenu dynamically
littleprince Feb 27, 2008 10:03 PM (in response to tomarenz)Thanks mores. it works perfectly.
-
35. Re: How to build rich:dropDownMenu dynamically
littleprince Feb 27, 2008 10:22 PM (in response to tomarenz)i got another question. Now the toolbar display as horizontally. How can i do vertical dynamic menu bar?
-
36. Re: How to build rich:dropDownMenu dynamically
littleprince Feb 28, 2008 5:53 AM (in response to tomarenz)i got the solution by binding the value to panelGrid.. but it doesnt look as nice as toolbar.
-
37. Re: How to build rich:dropDownMenu dynamically
ilya_shaikovsky Feb 28, 2008 6:41 AM (in response to tomarenz)just re-use our styles ;) You may explore the classes for the toolBar via fireBug.
-
38. Re: How to build rich:dropDownMenu dynamically
nelsonfg Apr 2, 2008 3:44 PM (in response to tomarenz)I'm making a project implementing Seam, and I want generate a dynamic menu from a database using richfaces ¿Can somebody give me links o example code to see how this works? or ¿Where can i find the full source code to do a dynamic drop down menu using richfaces?
-
39. Re: How to build rich:dropDownMenu dynamically
ilya_shaikovsky Apr 3, 2008 5:35 AM (in response to tomarenz)there example pieces was listed. If you need more - you need to start with binding itself exploration.
-
40. Re: How to build rich:dropDownMenu dynamically
gustavodelgado Apr 4, 2008 1:08 AM (in response to tomarenz)Hi,
After update the jars to richfaces 3.2.0, my dinamic dropdown menu stop work.
Ex:
<rich:toolBar>
<rich:dropDownMenu binding="#{Page4.menuTeste}" />
</rich:toolBar>
And the backing bean:
private HtmlDropDownMenu menuTeste = new HtmlDropDownMenu();
public HtmlDropDownMenu getMenuTeste() {
menuTeste.setValue("Menu teste");
HtmlMenuItem menuItem = new HtmlMenuItem();
menuItem.setValue("Item 1");
menuItem.setSubmitMode("ajax");
menuTeste.getChildren().add(menuItem);
return menuTeste;
}
public void setMenuTeste(HtmlDropDownMenu menuTeste) {
this.menuTeste = menuTeste;
}
In previous version it works fine... -
41. Re: How to build rich:dropDownMenu dynamically
ilya_shaikovsky Apr 7, 2008 5:19 AM (in response to tomarenz)known issue. It's one of the first candidates to 3.2.0 SP1
-
42. Re: How to build rich:dropDownMenu dynamically
westdwestd Apr 23, 2008 2:46 PM (in response to tomarenz)Hi I'm struggling to register an action with a dynamically created context menu. My context menu is displaying just fine, but when I select an item from it on the next request to the server I get an exception indicating that my seam bean cannot be found. Any help with this would be greatly appreciated, I've burned alot of time on it to no avail yet.
My java code to create the context menu is as follows:
@Name("linkedDocsBean")
@Scope(ScopeType.CONVERSATION)
public class LinkedDocumentsManagementBean implements Serializable {
...
public ContextMenu getContextMenu() {
FacesContext fc = FacesContext.getCurrentInstance();
ELContext el = fc.getELContext();
ContextMenu menu = new ContextMenu();
menu.setEvent("onclick");
for (DocumentType documentType : getOtherDocumentTypes()) {
HtmlMenuGroup group = new HtmlMenuGroup();
group.setValue(documentType.getName());
for (DocumentTypeIndex docTypeIndex : documentType.getDocumentTypeIndexList()) {
HtmlMenuItem item = new HtmlMenuItem();
item.setValue(docTypeIndex.getIndex().getName());
MethodExpression me = fc.getApplication().getExpressionFactory().createMethodExpression(
el, "#{linkedDocsBean.onIndexSelected()}", null, new Class[] {});
item.setActionExpression(me);
group.getChildren().add(item);
}
menu.getChildren().add(group);
}
return menu;
}
public void onIndexSelected() {
System.out.println("event");
}
...
}
My context menu is linked like so:
<h:outputLink value="#">
add link
<rich:contextMenu binding="#{linkedDocsBean.contextMenu}" >
</rich:contextMenu>
</h:outputLink>
I'm getting the following exception:
javax.el.PropertyNotFoundException: /pages/category/linkedDocumentTypeForm.xhtml @52,65 binding="#{linkedDocsBean.contextMenu}": Target Unreachable, identifier 'linkedDocsBean' resolved to null
at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:95)
at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:244)
at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:249)
at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:249)
at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:249)
at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:249)
at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:249)
at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:249)
at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:249)
at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:249)
at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:249)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:193)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:80)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
at org.ajax4jsf.Filter.doFilter(Filter.java:175)
at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:619)
Thanks. -
43. Re: How to build rich:dropDownMenu dynamically
umeshkarthy Jan 27, 2009 8:05 AM (in response to tomarenz)"mores" wrote:
"Dsleeper" wrote:
Can anybody from the richfaces team show a code example of how this should be done?
Ie a complete createMethodExpression code example?
I finally got this to work:<rich:dropDownMenu binding="#{webmenu.myMenu}" > </rich:dropDownMenu>
public class WebMenu { private static org.slf4j.Logger _log = org.slf4j.LoggerFactory.getLogger( WebMenu.class ); private String lastItem = "None"; public org.richfaces.component.html.HtmlDropDownMenu getMyMenu() { _log.trace( "Creating menu" ); org.richfaces.component.html.HtmlDropDownMenu menu = new org.richfaces.component.html.HtmlDropDownMenu(); menu.setValue( "Security Actions" ); org.richfaces.component.html.HtmlMenuItem menuItem = new org.richfaces.component.html.HtmlMenuItem(); String subOption = "Sec. Change Passsword"; menuItem.setValue( subOption ); javax.faces.application.Application app = javax.faces.context.FacesContext.getCurrentInstance().getApplication(); javax.faces.el.MethodBinding mb = app.createMethodBinding( "#{webmenu.onItemClick}", new Class[] { javax.faces.event.ActionEvent.class } ); menuItem.setActionListener( mb ); menu.getChildren().add( menuItem ); return( menu ); } public void onItemClick( javax.faces.event.ActionEvent event ) { Object obj = event.getSource(); if( obj instanceof org.richfaces.component.html.HtmlMenuItem ) { org.richfaces.component.html.HtmlMenuItem item = (org.richfaces.component.html.HtmlMenuItem)obj; if( item != null ) { lastItem = item.getValue().toString(); _log.trace( "Clicked On: " + lastItem ); } } } }
They key is to use actionListener and NOT action. These posts helped:
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=82&t=002888
http://balusc.blogspot.com/2006/06/communication-in-jsf.html
Hi, I am very new to JSF. Can someone explain me usage of "Action vs ActionListener". I tried using the above, but didnt help.
Please explaing what onClick method does too. when and where do we bind the action (to be performed) to the control? -
44. Re: How to build rich:dropDownMenu dynamically
dafunkel Jan 31, 2009 3:54 PM (in response to tomarenz)Hi,
How can I send a value to the menu action method (otherbean.action in above example) so that I know which menu item was clicked on.
Thanks