Here is a brandnew tutorial on Clay http://wiki.apache.org/shale/ShaleAndClayTutorial
-M On 2/21/07, Gary VanMatre <[EMAIL PROTECTED]> wrote:
>From: [EMAIL PROTECTED] >Hi All, > >A) I have a common address JSP which i want to use it in several other Jsps. >Having the content below and i want to set this address value in a common AddressVO object(POJO). > ><h:outputText value="Enter the address" /> ><h:inputText id="add1" value="#{pc_AddressVO.addLine}" /> > >B) I want to use this data in another jsp in the following manner. ><f:view> > <h:form id="myform" > > Enter Name : <h:inputText id="name1" value="#{pc_ClaimsDataBean.myVO.name}"/> > Enter Profession : <h:inputText id="prof1" value="#{pc_ClaimsDataBean.myVO.profession}" /> > <f:subview id="xyz"> > <jsp:include page="Address.jsp" /> > </f:subview> > Enter TCN : <h:inputText id="tcn1" value="#{pc_ClaimsDataBean.tcn}" /> > Enter Status : <h:inputText id="stat us1" v alue="#{pc_ClaimsDataBean.status}" /> > <f:subview id="abc"> > <jsp:include page="Address.jsp" /> > </f:subview> > <h:commandButton id="button1" value="Submit" action="#{pc_ClaimsManageBean.save}" /> > </h:form> ></f:view> > >C) In my ClaimsManageBean I want to set the data in my ClaimsDataBean in the follwoing manner > >ValueBinding bind1 = fc.getApplication().createValueBinding("#{pc_ClaimsDataBean}"); >ClaimsDataBean iniVO = (ClaimsDataBean)bind1.getValue(fc); >ValueBinding bind2 = fc.getApplication().createValueBinding("#{pc_AddressVO}"); >AddressVO initVO = (AddressVO)bind2.getValue(fc); >iniVO.setAddVO(initVO); > >But this will give a problem , the last value set in the AddressVO will be set in the DataBean i lose the previous value. >Is there a way i can make a reusable jsp which can be used in other JSPs several times. > What a re the other possible design strategies. > You can use Shale Clay to achieve this level of reuse [1]. Clay is an alternative templating solution that allows you to form JSF page composition using something other than JSP. Clay can also be used within a JSP. Clay has something called "symbols" that are a string substitution layer that is evaluated before a binding expression is created. There is a similar address example in the shale-clay-usecases [2]. Consider a fragment from the JSP page [3]: <f:subview id="address1"> <clay:clay id="address1" jsfid="addressPanel" managedBeanName="rolodex.selectedContact.residentialAddress" /> </f:subview> <f:subview id="address2"> <clay:clay id="address2" jsfid="foreignAddressPanel" managedBeanName="rolodex.selectedContact.businessAddress" /> </f:subview> The managedBeanName JSP tag attribute is a symbol. Its value will be replaced within the binding expression. For example: <component jsfid="street1Label" extends="baseLabel"> <attributes> <set name="value" value="#{messages['rolodex.address.street1']}" /> <set name="for" value="street1" /> </attributes> </component> <component jsfid="street1" extends="streetInput" id="street1"> <attributes> <set name="value" value="[EMAIL PROTECTED]" /> <set name="required" value="false" /> </attributes> </component> <component jsfid="street1Message" extends="baseMessage"> <attributes> <set name="for" value="street1" /> </attributes> Within this set of component definitions, "@managed-bean-name" will be replaced with "rolodex.selectedContact.residentialAddress" or "rolodex.selectedContact.businessAddress". Besides the symbol substitution layer, you also have visual inheritance similar to tiles. In the JSP example above, the first use of Clay will include the addressPanel. The second includes the foreignAddressPanel. Lets first look at the addressPanel. <!-- address table contains 5 rows of three columns --> <component jsfid="addressPanel" extends="panelGrid"> <attributes> <set name="columns" value="3" /> </attributes> <element renderId="1" jsfid="street1Label" /> <element renderId="2" jsfid="street1" /> <element renderId="3" jsfid="street1Message" /> <element renderId="11" jsfid="street2Label" /> <element renderId="12" jsfid="street2" /> <element renderId="13" jsfid="street2Message" /> <element renderId="21" jsfid="cityLabel" /> <element renderId="22" jsfid="city" /> <element renderId="23" jsfid="cityMessage" /> <element renderId="31" jsfid="stateLabel" /> <element renderId="32" jsfid="state" /> <element renderId="33" jsfid="stateMessage" /> <element renderId="41" jsfid="zipLabel" /> <element renderId="42" jsfid="zip" /> <element renderId="43" jsfid="zipMessage" /> </component> Next, the "foreignAddressPanel" extends the "addressPanel" adding the province and country data elements. <!-- foreign address panel adds province and country --> <component jsfid="foreignAddressPanel" extends="addressPanel"> <element renderId="34" jsfid="provinceLabel" /> <element renderId="35" jsfid="province" /> <element renderId="36" jsfid="provinceMessage" /> <element renderId="51" jsfid="countryLabel" /> <element renderId="52" jsfid="country" /> <element renderId="53" jsfid="countryMessage" /> </component> [1] http://shale.apache.org/shale-clay/index.html [2] http://people.apache.org/builds/shale/nightly/examples/shale-clay-usecases-20070221.zip [3] http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-clay-usecases/src/main/webapp/rolodex/jsprolodex.jsp?view=markup >Best Regards, >Pallavi Gary
-- Matthias Wessendorf http://tinyurl.com/fmywh further stuff: blog: http://jroller.com/page/mwessendorf mail: mwessendorf-at-gmail-dot-com