Stuart Russell wrote:
> Thanks for the quick response
>
> Trying out as I write this.
>
> However, a bit of confusion over the syntax.
> Can you explain
> 1. Does that mean that all of my pages have to be modified to have a
> different syntax for all of my components rather than
> use standard jsf syntax : action="#{mybackingbean.method}"
> would now be ??????___________
The JSP JSF tag handlers (and probably facelets) create a different
object for this property just because they believe this property is
different. Other properties may also require a MethodExpression
foo="#{do.some.action}"... however, I doubt Facelets handles this w/o a
custom facelets tag file entry. JSP requires a all it's properties to
be specified by the component author.
JSFTemplating passes through all properties to the component by default
without any assumptions about the component. Unfortunately, I haven't
added any handling for MethodExpression-type properties. JSFT *does* do
automatic type conversion, so it may be possible to leverage this to
work for all properties that use MethodExpressions... if you file a bug
(
https://jsftemplating.dev.java.net/issues -- must be logged in to file
an issue) I'll look into fixing this. One challenge, however, is that a
MethodExpression must represent the parameters of the Method being
invoked... I can default to no parameters and make a special case for
the property named "actionListener". Let me know if have other thoughts.
> 2. My whole application is controlled via the faces-config which I
> actually like. I dont want any decisions as to where
> a page "goes" next .
> How do I still use the navigation within the faces-config ? Can you
> provide a quick syntax example ?
action="$methodExpression{#{nextPage}}"
> 3. Dont quite understand your second solution ( which I feel is the
> one I should use.
> If I have a jsf file which has the following
> <?xml version="1.0"?>
> <jsp:root 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:jsp="http://java.sun.com/JSP/Page"
> xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
> <jsp:directive.page contentType="text/html" />
> <!-- This is a composition using a particular template -->
> <ui:composition template="layout.jsf">
> <ui:define name="title">Welcome to the TDMS Tools portal.</ui:define>
> <ui:define name="content">
> <div>
> <p> The TDMS tools application portal is indented as a
> centralised web
> site where by all useful TDMS tools and reports will be located.
> Bookmark this page for future reference.
> </p>
> </div>
> </ui:define>
> </ui:composition>
> </jsp:root>
>
>
> Now within layout.jsf , we have
> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
> <jsp:root xmlns:f="http://java.sun.com/jsf/core"
> xmlns:h="http://java.sun.com/jsf/html"
> xmlns:jsp="http://java.sun.com/JSP/Page"
> xmlns:webuijsf="http://www.sun.com/webui/webuijsf"
> xmlns="http://www.w3.org/1999/xhtml"
> xmlns:ui="http://java.sun.com/jsf/facelets" >
> <jsp:directive.page contentType="text/html" />
>
> <f:view contentType="text/html">
>
> <webuijsf:page xhtml="true">
> <webuijsf:html id="htmlheader">
>
> <webuijsf:head id="head2" >
> <f:facet name="title">
> <ui:insert name="title">Default Title</ui:insert>
> </f:facet>
> <link rel="stylesheet" type="text/css" href="css/main.css"/>
> </webuijsf:head>
>
> <webuijsf:body id="bodyheader">
>
> <webuijsf:form id="toplevelform">
>
> <div id="header">
> <f:subview>
> <ui:insert name="header">
> <ui:include src="header.jsf" />
> </ui:insert>
> </f:subview>
> </div>
>
> <div id="left">
> <f:subview>
> <ui:insert name="navigation" >
> <ui:include src="navigation.jsf"/>
> </ui:insert>
> </f:subview>
> </div>
>
> <div id="center">
> <br />
> <span class="titleText"> <ui:insert name="title" /> </span>
> <hr />
> <f:subview id="contentsubview">
> <ui:insert name="content">
> <div>
> <ui:include src="content.jsf"/> </div>
> </ui:insert>
> </f:subview>
> </div>
>
> <div id="footer">
> <ui:insert name="footer">
> <ui:include src="footer.jsf"/> </ui:insert>
> </div>
>
> </webuijsf:form>
>
> </webuijsf:body>
>
> </webuijsf:html>
> </webuijsf:page>
> </f:view>
>
> </jsp:root>
>
>
> Now in the content.jsf, this is where I have the button ( for example
> ) and a backing bean
> within my faces-config called MyBean.
>
> <webuijsf:button id="button1" action="#{MyBean.executeSomething}" />
>
> I take it that this is now incorrect ,
Either "webuijsf:button"'s CompoentFactory needs to support the "action"
property to convert it to a MethodExpression (see:
https://jsftemplating.dev.java.net/source/browse/jsftemplating/src/java/com/sun/jsftemplating/component/factory/sun/ButtonFactory.java?rev=HEAD&view=markup),
or I need to change JSFT to automatically convert #{} to a
MethodExpression instead of a ValueExpression.
You of course can use one of the 2 work-a-rounds I suggested as well
(event/handler, or $methodExpression{#{MyBean.executeSomething}}. And,
of course, you could provide your own alternate to the Factory mentioned
above (if you do this, you might consider contributing it back to JSFT).
> but Im unsure based on what you have written below, as to
> what I should put as the syntax ( forgive me for saying, but there is
> not much in the way
> of documentation for the whole templating , some really good examples
> using jsf components
> would be great . What about the Facelets example web app that doesnt
> seem to be available online
> ? any ideas ?
Yes, I apologize. The documentation is lacking to say the least. This
is something I hope to address over Christmas break.
> ) for the action , and do I have to do this in all of the pages ?
Unless I fix the issue to do this automatically... I'm beginning to
think I will do this soon -- probably faster to do this than to explain
it again. :)
> Finally, is there any other aspect that I have to this with ???
> valueexpression I presume as ok ?
ValueExpressions are the default, so it should "just work". This
includes inside static text in the template, and virtually any other
area (conditions, properties, etc.). Also JSFT does automatic type
conversions for most types... so if a property expects a boolean, or a
integer... it'll convert your String (or whatever) to that value
automatically (same w/ handler inputs / outputs).
> If you can answer these I would really much appreciate it and then I
> can get this application
> completed at the weekend for demoing internally next week before wrap
> up to send out
> to our external manufacturers.
Good luck! Let me know if you have more issues / questions.
Ken
>
>
> Stu
>
>
>
>
>
>
> Ken Paulsen wrote:
>
>>
>> Hi Stuart,
>>
>> If you're not already on the dev_at_jsftemplating.dev.java.net email
>> alias, you may want to join that list. You can find it on the JSFT
>> web site (https://jsftemplating.dev.java.net).
>>
>> The problem is that JSFT does wrap MethodExpressions automatically by
>> default. For now, it's up to the individual ComponentFactory's to
>> create a MethodExpression (instead of a ValueBinding, which it does
>> do by default). I may enhance JSFT to try to do this correctly in
>> the future... at least for action/actionListener properties, which
>> are standard.
>>
>> There are 2 easy ways around this problem, and probably many other
>> approaches as well. The reason this issue hasn't been targeted to be
>> addressed sooner is that most JSFTemplating developers use the
>> "command" event instead of using an action/actionListener. To do
>> this you would do:
>>
>> <webuijsf:hyperlink action="gosomewhere">
>> <ui:event type="command">
>> navigate("/nextPage.jsf");
>> </ui:event>
>> </webuijsf:hyperlink>
>>
>> No need for any faces-config.xml file entries at all. Instead of
>> "navigate" you can also do "redirect". And... you may also do any
>> king of processing you can think of. You can have as many handlers
>> per event as you'd like... they get executed in the order you write
>> them. You can do coditionals if ("#{something}=foo") { doThis(); },
>> etc. There is some information on this at:
>> https://jsftemplating.dev.java.net/doc/ More information on this
>> will be published soon (I plan to focus on this during my Christmas
>> vacation).
>>
>> The 2nd way to get around this problem uses a special syntax to
>> create a MethodExpression from within the template file:
>>
>> <webuijsf:hyperlink action="$methodExpression{gosomewhere}" />
>>
>> That should work for an "action" property. The following should work
>> for an actionListener property:
>>
>> <webuijsf:hyperlink action="$methodExpression{gosomewhere,true}" />
>>
>> For a MethodBinding (only works for actionListener property on JSF
>> 1.1 components):
>>
>> <webuijsf:hyperlink action="$methodBinding{gosomewhere}" />
>>
>> I hope this helps... let me (and the rest of the dev_at_jsftemplating
>> email list) know if you have more questions / problems. I am taking
>> time off at the moment to do some work on my house... so I may not
>> respond quickly. The email list is your best resource.
>>
>> Good luck!
>>
>> Ken
>>
>> Stuart Russell wrote:
>>
>>> Hi ken
>>> Im a senior j2ee architect within engineering and I require your
>>> assistence if possible,
>>>
>>> Basically I have had to convert a facelets app over to using
>>> jsftemplating to allow the woodstock components + dynafaces to
>>> function correctly.
>>> I am getting the error within my application
>>>
>>> *type* Exception report
>>>
>>> *message*
>>>
>>> *description* _The server encountered an internal error () that
>>> prevented it from fulfilling this request._
>>>
>>> *exception*
>>>
>>> org.apache.jasper.JasperException: javax.servlet.ServletException:
>>> Could not find type conversion for type "class
>>> javax.faces.el.MethodBinding" (value = "sqlReports"
>>>
>>> org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:532)
>>>
>>>
>>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:408)
>>>
>>>
>>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
>>>
>>> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>> *root cause*
>>>
>>> javax.servlet.ServletException: Could not find type conversion for
>>> type "class javax.faces.el.MethodBinding" (value = "sqlReports"
>>> javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
>>>
>>> org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:699)
>>>
>>>
>>> org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:670)
>>>
>>> org.apache.jsp.index_jsp._jspService(index_jsp.java:54)
>>> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
>>>
>>>
>>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
>>>
>>> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>> *root cause*
>>>
>>> java.lang.IllegalArgumentException: Could not find type conversion
>>> for type "class javax.faces.el.MethodBinding" (value = "sqlReports"
>>>
>>> com.sun.jsftemplating.util.TypeConverter.asType(TypeConverter.java:260)
>>>
>>> com.sun.jsftemplating.component.factory.ComponentFactoryBase.setOption(ComponentFactoryBase.java:169)
>>>
>>>
>>> com.sun.jsftemplating.component.factory.ComponentFactoryBase.setOptions(ComponentFactoryBase.java:104)
>>>
>>>
>>> com.sun.jsftemplating.component.factory.basic.GenericFactory.create(GenericFactory.java:86)
>>>
>>>
>>> com.sun.jsftemplating.component.ComponentUtil.createChildComponent(ComponentUtil.java:397)
>>>
>>>
>>> com.sun.jsftemplating.layout.descriptors.LayoutComponent.getChild(LayoutComponent.java:277)
>>>
>>>
>>> com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:528)
>>>
>>>
>>> com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:543)
>>>
>>>
>>> com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:543)
>>>
>>>
>>> com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:482)
>>>
>>>
>>> com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:520)
>>>
>>>
>>> com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:543)
>>>
>>>
>>> com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:543)
>>>
>>>
>>> com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:543)
>>>
>>>
>>> com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:543)
>>>
>>>
>>> com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:482)
>>>
>>>
>>> com.sun.jsftemplating.layout.LayoutViewHandler.createView(LayoutViewHandler.java:234)
>>>
>>>
>>> com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:201)
>>>
>>> com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
>>>
>>> com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
>>>
>>> com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.execute(PartialTraversalLifecycle.java:94)
>>>
>>> javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
>>>
>>> org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:699)
>>>
>>>
>>> org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:670)
>>>
>>> org.apache.jsp.index_jsp._jspService(index_jsp.java:54)
>>> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
>>>
>>>
>>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
>>>
>>> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>> *note* _The full stack trace of the root cause is available in the
>>> Apache Tomcat/6.0.10 logs._
>>>
>>>
>>> This is caused by the action= or actionExpression= on any one of
>>> my components
>>> eg <webuijsf:hyperlink action="gosomewhere" />
>>>
>>> I obviously have this defined in my faces config file to redirect to
>>> another page.
>>>
>>> I am completely dead in the water as there is little in the way of
>>> documentation to using facelets syntax within jsftemplating ( which
>>> seems to work ).
>>>
>>> I have no idea what I have to set up within my web.xml to activate
>>> templating . Do i requre something else ??
>>>
>>>
>>> I would really appreciate your help in this matter as I am getting
>>> pressure to complete this project .
>>>
>>> Thanks
>>> Stu
>>>
>>>
>