>From: Richard Wallace <[EMAIL PROTECTED]> > > Hello again, > > Sorry if I'm getting to be a pest, but I really like Clay and want to > understand it better. So, here are my questions of the day: > > Can you (or how do you) use resource bundles in the clay config files? > I'm trying to get to a place where I can use the symbol replacement > features of Clay like in the use-cases, specifically the templating. > So, I'd have a component similar to the basePage component with a > layout. Then in the layout I'd use @title for the page title. But how > can I use a resource bundle to specify the title? Additionally, if I > define label components in the clay config files, how would I use values > from resource bundles for them? And, if I use resource bundles in the > clay configs, is that just going to use the default or system locale, or > will it use the users session locale?
There are a couple ways you can handle this in clay. The resource bundle is a JSP tag in JSF which didn't work in Clay. Manfred Kluge contributed a resource bundle component that solves this problem. Shale core also has a managed bean that behaves like a JSF map wrappered resource bundle. It's in the utils package (LoadBundle). Craig wrote this one so the java doc is pretty good. The cool thing about the managed bean solution is that you can specify a scope. So, if you used the bundle component you might consider: <span jsfid="loadBundle" basename="org.apache.shale.usecases.view.Bundle" var="messages"/> <title>#{messages['@title']}</title> > > I was trying to get my headers and footers put together yesterday and > ran into a problem doing images. My first impulse was to use an > tag with a jsfid="graphicImage" attribute. I think that I gave the graphic image clay component XML definition a jsfid of "image". >But that didn't work as > expected. Since this is a header that will be used in files that could > be in any directory I can't really use relative paths because there is > no way to know what the current working directory is so I need to > specify the full path. Would the best way to do this be something like > and define @images to be > "#{facesContext.externalContext.request.contextPath}/images" > in the clay-config.xml? Similarly, what's the best way to include > stylesheets? Before I discovered the power of symbols I used > > rel="stylesheet" type="text/css" > href="#{facesContext.externalContext.request.contextPath}/styles/default.css" > />, which is > a bit of a mess. So, would it be better to define a @styles symbol? > This is a good chance to talk about a new shale remoting feature that allows you to access static resources like images and style sheets from the class path. I created a couple components in the rolodex usecase that pull images from the class path to demonstrate. I really like this idea because you can create a component library that is self contained and self registering. Just drop it into the project and it contains all the resources. The "static" folder is the default convention and the rest is the class path. headerSorter.ascImage=/static/org/apache/shale/usecases/rolodex/up.gif.faces headerSorter.descImage=/static/org/apache/shale/usecases/rolodex/down.gif.faces > In the use-cases, dataTables are built strictly using components in the > clay config files. Is this the only way to construct them? I was > almost hoping for something more like: > The extreme HTML rolodex example shows how this can be done: <table jsfid="dataTable" class="contacts" value="[EMAIL PROTECTED]" var="e" rows="5" first="0" headerClass="contactsHeader" rowClasses="contactsRow1, contactsRow2" allowBody="true"> <caption jsfid="webPager" prevPageStyleClass="linkPrev" pageLinksStyleClass="links" nextPageStyleClass="linkNext" captionStyleClass="caption" facetName="header" allowBody="false"> Mock Page Links </caption> <tbody id="name" jsfid="column" class="contactsHeader" allowBody="true"> <th jsfid="headerSorter" facetName="header" allowBody="false" value="#{messages['rolodex.contactTable.nameColumn.title']}" sortBy="name"> Contacts </th> <tr jsfid="webPager" prevPageStyleClass="linkPrev" pageLinksStyleClass="links" nextPageStyleClass="linkNext" captionStyleClass="caption" facetName="header"/> <tr jsfid="commandLink" value="#{e.name}" action="[EMAIL PROTECTED]" immediate="true" allowBody="true"> <td jsfid="param" name="selectedName" value="#{e.encodedName}" allowBody="false"> <a href="#">ABC Company</a> </td> </tr> </tbody> </table> > > or something similar. Is that possible? > Depending on how clean you want your HTML, you can add the JSF component specific properties in an XML file or in the HTML. The example is also defined using a more conservative HTML pure approache: HTML template: <span jsfid="contactTable"> <table class="contacts"> <tr class="contactsHeader"> <td> Contacts </td> </tr> <tr class="contactsRow1"> <td> <a href="#">ABC Company</a> </td> </tr> <tr class="contactsRow2"> <td> <a href="#">XYZ Company</a> </td> </tr> </table> </span> XML Config: <component jsfid="nameColumn" extends="column" id="name"> <element renderId="1" jsfid="headerSorter" facetName="header"> <attributes> <set name="value" value="#{messages['rolodex.contactTable.nameColumn.title']}" /> <set name="sortBy" value="name"/> </attributes> </element> <element renderId="2" jsfid="commandLink"> <attributes> <set name="value" value="#{e.name}" /> <set name="action" value="[EMAIL PROTECTED]" /> <set name="immediate" value="true"/> </attributes> <element renderId="1" jsfid="param"> <attributes> <set name="name" value="selectedName"/> <set name="value" value="#{e.encodedName}"/> </attributes> </element> </element> </component> > One last question while I'm on the subject. One thing that I'd like to > be able to do with dataTables is have a single value be used to create > more than one row. So, for instance, we might have a list of bugs. For > each bug we may want 2 rows, the first being the short description, who > submitted it and when and then the second row being a more detailed > comment. The second row could be shown/hidden by the user with DHTML so > they could get a better idea of what is the issue is. I did this with > the myfaces dataList component in JSP for a report once, manually > building the table elements with a bunch of verbatims and such. Would I > have to do the same with Clay (minus the verbatims, of course)? How > would I do that? If I tried to do it in the clay-config.xml I would > need to do something like: You can use myfaces components in Clay. Others might be able to share their experiences. Another option might be the Clay for each component. The bodyJsfid holds the template you want included for each row in the list. It might look something like this: <table jsfid="clayForEach" var="e" value="mybean.bugs" bodyJsfid="classpath*:org/acme/bugslist.html" allowBody="false"> <tr><td>Mock row </table> buglist.html <tr><td>#{e.bugName}</td><td>#{e.comment}</td></tr> > > There has got to be a better way. Any ideas? > > Thanks, > Rich > > PS Sorry for the length of the message, but I'm really excited about > Clay and the possibilities it gives me and my web designers. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] >