dev@jsftemplating.java.net

Re: JSFtemplating/Woodstock Setup problem?

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Tue, 12 Dec 2006 18:57:39 -0800

Hi Karam,

I'm cc'ing the dev alias... I hope that's OK w/ you.

Attached are the before and after pages for Masthead.jsp. Some things
to note... JSFTemplating allows Object types which can be expressed via
EL expressions (either $something{something} or #{something}
expressions). It also does not do any type conversion from property
values automatically (it may in the future, but doesn't now). So
attributes like "immediate" that expect a boolean need to look like:

    immediate="#{false}"

You'll see a couple of these changes in the mh.jsf. Also, the Woodstock
components in JSFTemplating have a "sun:" prefix. This is mostly b/c we
defined this before woodstock defined what they were going to use (it
was "ui:" which conflicted w/ another component set when we defined
it). So you'll notice that all "webuijsf:" prefixes are changed to
"sun:". I removed the "f:view" tags which are needed for JSP b/c JSP
isn't exclusively a JSF format, these aren't needed for JSFTemplating.
Facets look different, I made a comment in the new file showing this.
Loading resources is also different (done via a handler), I also
demonstrated this.

Their example uses property files and managed beans that aren't in my
environment... the page still comes up for me, but may not function
correctly b/c these are missing. If you add them or change them to your
own code it should work. A note about processing buttons... they do:

    actionExpression="#{MastheadBean.consolePage1Clicked}"

You can also do this. However, JSFTemplating has an additional feature
(one of its biggest features) which allows you to do this instead:

    <!command
       println("Hello World!");
       setSessionAttribute(key="foo" value="bar");
>

These are calls to "Handlers" which is where you can place your custom
business logic. You can then re-use these anywhere you'd like, and of
course you can use the built-in handlers as well (like those above).
This often eliminates the need for a managed bean (Java code) completely.

I hope this helps!

Ken

Karam Singh Badesha wrote:
> Hi Ken/Anissa,
> I got a simple example working. So thats good. With woodstock
> components there is example.war file in which there are bunch of
> example files. Now is it possible to just take any one of them, say
> example/faces/masthead/Masthead.jsp and show how it will look using
> jsftemplating (actual code). Because when I look at the example code
> in the Masthead.jsp file, there are lot of things there and I don't
> know what would be the equivalent of that using jsftemplating. Is
> there something I can look at to understand this more.
>
> thanks
> Karam
>
> Ken Paulsen wrote:
>>
>> Hi Karam,
>>
>> Did you put it in the WEB-INF directory or the WEB-INF/lib
>> directory? The "jasper" message you are getting seems to indicate
>> that you are using JSP's, which should not be the case of
>> JSFTemplating files (which is what you have below).
>>
>> Your directory structure should look like this in your web application:
>>
>> /WEB-INF/faces-config.xml (optional)
>> /WEB-INF/web.xml
>> /WEB-INF/lib/dataprovider.jar (woodstock requirement)
>> /WEB-INF/lib/json.jar (woodstock requirement in newest version... I
>> think)
>> /WEB-INF/lib/webui-jsf (woodstock)
>> /WEB-INF/lib/webui-jsf-suntheme.jar (woodstock)
>> /WEB-INF/lib/jsftemplating.jar (jsftemplating)
>> /WEB-INF/lib/jsftemplating-dynafaces-0.1.jar (new jsftemplating
>> requirement)
>> /yourfile.jsf
>>
>> I "think" that's all that's required.
>>
>> Just yesterday I integrated with Ed Burn's "Dynamic Faces" project.
>> This introduced "jsftemplating-dynafaces-0.1.jar" as a requirement to
>> work with the "tip" of JSFTemplating. There is a branch prior to
>> this integration called "JSF1_1" which does not have this
>> requirement. It also works with JSF 1.1, JSF 1.2 will be a
>> requirement going forward. I hope to remove the requirement to
>> include the Dynamic Faces .jar files, but until I can get Ed to make
>> some changes this will continue.
>>
>> If this doesn't help you get going, you can send me your web
>> application and I can take a look to see what might be causing the
>> problem. Also, you may find the "demo" application on the
>> JSFTemplating site may be a good example to see what is required in
>> the app... esp. wrt the build environment (it has ant build.xml files
>> that are already setup to compile with "apt", etc.).
>>
>> Good luck!
>>
>> Ken
>>
>> P.S. Unless there is Sun confidential information, please feel free
>> to use the "dev_at_jsftemplating.dev.java.net" email alias. There are
>> others inside Sun and outside that may provide additional help... or
>> your question may help someone else experiencing the same problems!
>> ;) If you haven't already subscribed to that alias you may want to
>> do that by going here:
>> https://jsftemplating.dev.java.net/servlets/ProjectMailingListList
>>
>> Karam Singh Badesha wrote:
>>> Ken/Anissa,
>>> Here is my first problem just setting up the netbeans env. I have
>>> copied all the woodstock jar files and jsftemplating jar files into
>>> the WEB-INF folder and there are no problems in building the
>>> following code from jsftemplating website:
>>> <sun:page>
>>> <sun:html>
>>> <sun:head title="Pick A Number" />
>>> <sun:body>
>>> <sun:form>
>>> <sun:textField label="Pick a Number:"
>>> text="#{requestScope.num}" />
>>> <staticText value="<br />You picked:
>>> #{requestScope.num}<br />" />
>>> <sun:button text="OK" />
>>> </sun:form>
>>> </sun:body>
>>> </sun:html>
>>> </sun:page>
>>>
>>> And here is the exception I get.
>>>
>>> org.apache.jasper.JasperException: /index.jsp(6,62) #{...} not
>>> allowed in a template text body.
>>>
>>> Is there a page which describes how to debug in this environment?
>>>
>>> thanks
>>> Karam


<jsp:root version="2.0"
          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">

<jsp:directive.page contentType="text/html" />
                   
<f:view>
  <webuijsf:page id="page2" >
    <webuijsf:html id="html2" >
      <f:loadBundle basename="com.sun.webui.jsf.example.resources.Resources" var="msgs" />
        <webuijsf:head id="head2" title="#{msgs.masthead_title}">
          <webuijsf:link rel="shortcut icon" url="/images/favicon.ico" type="image/x-icon" />
        </webuijsf:head>
        <webuijsf:body id="body2" >
            <webuijsf:form id="form2">
              
              <!-- Masthead with Attributes -->
              <webuijsf:masthead id="masthead" serverInfo="#{MastheadBean.server}" userInfo="#{MastheadBean.user}"
                           dateTime="true" notificationMsg="#{msgs.masthead_notificationmsg}" jobCount="0"
                           productImageURL="/images/example_primary_masthead.png" productImageDescription="#{msgs.mastheadAltText}"
                           utilities="#{MastheadBean.links}"
                           alarmCounts="#{MastheadBean.alarms}" >
                           
                <!-- Utility Bar Facets -->
                <f:facet name="consoleLink" >
                  <webuijsf:hyperlink id="hyp1" toolTip="#{msgs.masthead_consoleLink}"
                                actionExpression="#{MastheadBean.consolePage1Clicked}" immediate="true" />
                </f:facet>
                <f:facet name="versionLink" >
                  <webuijsf:hyperlink id="hyp2" onClick="javascript: var versionWin = window.open('/example/faces/masthead/Version.jsp', 'VersionWindow','scrollbars,resizable,
                                 width=650,height=500,top='+((screen.height - (screen.height/1.618)) - (500/2))+',left='+((screen.width-650)/2) ); versionWin.focus();
                                 if(window.focus){versionWin.focus();} " immediate="true"
                                 toolTip="#{msgs.masthead_versionLink}" actionExpression="#{MastheadBean.versionPage1Clicked}"/>
                </f:facet>
                <f:facet name="logoutLink">
                  <webuijsf:hyperlink id="hyp3" actionExpression="#{MastheadBean.logoutPage1Clicked}" toolTip="#{msgs.masthead_logoutLink}" immediate="true" />
                </f:facet>
                <f:facet name="helpLink" >
                  <webuijsf:hyperlink id="hyp4" actionExpression="#{MastheadBean.helpPage1Clicked}" toolTip="#{msgs.masthead_helpLink}" immediate="true" />
                </f:facet>
              </webuijsf:masthead>
   
              <!-- Breadcrumbs -->
              <webuijsf:breadcrumbs id="breadcrumbs">
                <webuijsf:hyperlink id="hyp5" actionExpression="#{IndexBean.showIndex}" text="#{msgs.exampleTitle}"
                              toolTip="#{msgs.index_title}" immediate="true"
                              onMouseOver="javascript:window.status='#{msgs.index_breadcrumbMouseOver}'; return true"
                              onMouseOut="javascript:window.status=''; return true"/>
                <webuijsf:hyperlink id="hyp6" actionExpression="#{MastheadBean.goToMastheadIndex}"
                              text="#{msgs.masthead_title}" toolTip="#{msgs.masthead_titleToolTip}"
                              onMouseOver="javascript:window.status='#{msgs.masthead_breadcrumbMouseOver}'; return true"
                              onMouseOut="javascript:window.status=''; return true" immediate="true"/>
                <webuijsf:hyperlink id="hyp7" text="#{msgs.masthead_masthead1Title}" />
              </webuijsf:breadcrumbs>
              
              <!-- Alert -->
              <webuijsf:alert id="message" type="information" summary="#{MastheadBean.message}" rendered="#{MastheadBean.isRendered1}" />
              
              <!-- Page Title -->
              <webuijsf:contentPageTitle id="pagetitle" title="#{msgs.masthead_pageTitle1}" helpText="#{msgs.masthead_helpText1}" />
             
              <div class="ConMgn_sun4">
              <br/>
         
              <!-- Hyperlink to Popup window with Secondary Masthead -->
              <webuijsf:hyperlink id="hyperlinkpopup" text="#{msgs.masthead_link}" toolTip="#{msgs.masthead_linkToolTip}" immediate="true"
                             onClick="javascript: var popupWin = window.open('/example/faces/masthead/Popup.jsp','PopUpWindow','scrollbars,resizable,width=650,
                             height=500,top='+((screen.height - (screen.height/1.618)) - (500/2))+',left='+((screen.width-650)/2) ); popupWin.focus();
                             if(window.focus){popupWin.focus();} return false;" />
              </div>
              
            </webuijsf:form>
          </webuijsf:body>
    </webuijsf:html>
  </webuijsf:page>
</f:view>
</jsp:root>

setResourceBundle(key="msgs" bundle="com.sun.webui.jsf.example.resources.Resources"); /> // Removed, see above /* * Facets have a different syntax in JSFTemplating, the following * is the old syntax for the facet defined above left here for * comparison purposes. * * * * */ // Note the use of a double quote before any line that should be // rendered directly to the output stream. "
"
"