-
1. Re: Dynamic Action Name
stephen May 8, 2009 1:06 PM (in response to rajibjana)See the
Passing actions
section here http://www.ibm.com/developerworks/java/library/j-facelets/#N1038E -
2. Re: Dynamic Action Name
dozer May 18, 2009 3:17 AM (in response to rajibjana)Hi,
I can get this going for commandButtons with the syntax as below
<h:commandButton action="#{actionBean[action]}" .../>
But i can't get it going for slink.
<s:link action="#{actionBean[editMethod]}" ... />
I get the following error on the seam debug page
Exception during request processing: Caused by javax.el.PropertyNotFoundException with message: "Target Unreachable, identifier 'actionBean' resolved to null"
Has anyone got it going for slinks?
-
3. Re: Dynamic Action Name
rajibjana May 18, 2009 10:33 AM (in response to rajibjana)Hi,
I am still not able to solve my problem.
I tried to implement custom tag as described in the link( suggested by Stephen), but could not able to get it working.
pls. let me know how you get <h:commandButton action="#{actionBean[action]}" .../>
working?
Template:
1. template.xhtml
<f:view contentType="text/html"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a="http://richfaces.org/a4j"
xmlns:s="http://jboss.com/products/seam/taglib">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>#{messages['app.title']}</title>
<link rel="shortcut icon" href="#{request.contextPath}/favicon.ico"/>
<a:loadStyle src="resource:///stylesheet/theme.xcss"/>
<a:loadStyle src="/stylesheet/theme.css"/>
</head>
<body>
<div id="header">
<ui:insert name="header">
<ui:include src="menu.xhtml">
<ui:param name="projectName" value="#{messages['app.title']}"/>
</ui:include>
</ui:insert>
</div>
<div id="center">
<h:messages id="messages" globalOnly="true" styleClass="message"
errorClass="errormsg" infoClass="infomsg" warnClass="warnmsg"
rendered="#{showGlobalMessages != 'false'}"/>
<ui:insert name="body">
</ui:insert>
</div>
</body>
</html>
</f:view>
2. menu.xtml
<a4j:form
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:r="http://www.customfacelet.com/jsf"
id="menu">
<rich:toolBar>
<rich:toolBarGroup>
<h:commandLink action="#{actionBean}" value="Add">
</h:commandLink>
</rich:toolBarGroup>
</rich:toolBar>
</a4j:form>
Xhtml: UIControl_FWD.xhtml
<ui:include xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a="http://richfaces.org/a4j"
template="layout/template.xhtml"
src="/UIControl.xhtml">
<ui:param name="actionBean" value="#{dropDownBean.add}"/>
</ui:include>
Xhtml: UIControl.xhtml
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a="http://richfaces.org/a4j"
template="layout/template.xhtml">
<ui:define name="body">
<rich:panel>
<f:facet name="header">UIControl</f:facet>
<h:form id="dropDownBeanForm">
</h:form>
</rich:panel>
</ui:define>
</ui:composition>
I have dropDownBean session bean (stateful) with getadd method. When the app is executed, it shows the error "Property 'add' not found on type org.javassist.tmp.java.lang.Object_$$_javassist_2"
I am stuck with this problem and need help. -
4. Re: Dynamic Action Name
dozer May 19, 2009 5:33 AM (in response to rajibjana)OK,
Here an example of how i did it,
I;ve got a file called leadDetail.xhtml as shown below<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jstl/core" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j"> <h:form> ... removed code... <div class="buttons clearfix"> <h:commandButton action="#{actionBean[action]}" value="Save" styleClass="btn alignright btn_green"/> </div> </h:form> </ui:composition>
then in my xhtml file i had the following
<ui:include src="/WEB-INF/incl/leadDetail.xhtml" > <:param name="actionBean" value="#{backingBean}"/> <:param name="action" value="save"/> </ui:include>
where backingBean is my backing bean
action is the name of the method to callHopes this helps,
Let me know if you get it going for slinks -
5. Re: Dynamic Action Name
rajibjana May 19, 2009 3:34 PM (in response to rajibjana)Thanks Darrell, its now working.
But action="#{actionBean[action]}" does not work if "action" has arguments.
But , action="#{actionBean.action(arg)}" works when used normally(i.e bean name is not passed by ui:param).
I tried with action="#{actionBean[action(actionParm)]}" where actionParam is passed by ui:param, but it does not work. I have to use f:param/f:setPropertyActionListener.
slink is not working for me also. -
6. Re: Dynamic Action Name
schmu May 28, 2009 9:46 AM (in response to rajibjana)Have you found any solution for this problem?? I'd like to do the same thing...
Thank you in advance!
-
7. Re: Dynamic Action Name
vsq Jun 5, 2009 1:00 PM (in response to rajibjana)h:commandLink instead of s:link seems to work:
<h:form>
<h:commandLink value="label" action="#{actionBean[action]}" />
</h:form>