>From: "Mosimann Matthias" [EMAIL PROTECTED]
>
>Hy Everyone
>I experimented a little bit with JSF with Kito Mann's book "Java Server Faces in
>Action". Now I'm wonder if it is possible to make a JSP(View) configurable with a
>simple XML File. So you will be able to disable and enable some elements with a
> simple XML File.
 
>something like this:
>...
><street enable=no />
><postal-zip enable=yes />
>...
>...
><street enable=no />
><postal-zip enable=yes />
>...
>
>So the whole form would display only the postal zip label
>and input text field but not a label and an input text field for
>the street attribute.
>
>
>...
><street enable=no />
><postal-zip enable=yes />
>...
>
>So the whole form would display only the postal zip label and input
>text field but not a label and an input text field for the street attribute.
>
>If someone ask himself: Why this should makes sence or not. I say
>it makes sence. One forms can be used several times and the forms
>intself is highly configurable.
>
>
>Has allready someone done this work?
>
 

Shale Clay will provide you with these kinds of reuse options
in JSP or as an alternative to JSP.
 
For example, lets say that our app needed a basic person.  That
classification of person has a first and middle name.

However, in some places in the app, we need a full person that
extends the basic persons widgets adding a name prefix,
middle name and suffix. 
 
To take this a step further, what if we needed a business person
that extends the attributes of the full person adding a business name.
 
Clay provides a meta-data layer that it uses to construct a component
subtree that is attached to an existing tree.  This meta-data is a layer
of indirection that gives the ability to use inheritance in addition to composition. 

The following is an example of the metadata inheritance:
 
 <!--  base error message -->
 <component jsfid="baseMessage" extends="message"
  allowBody="false">
  <attributes>
   <set name="style" value="color:red" />
  </attributes>
 </component>
 <component jsfid="firstNameLabel" extends="baseLabel">
  <attributes>
   <set name="value" value="First Name:" />
   <set name="for" value="firstName" />
  </attributes>
 </component>
 <component jsfid="firstName" extends="inputText" id="firstName">
  <attributes>
   <set name="value" value="[EMAIL PROTECTED]}" />
   <set name="size" value="20" />
   <set name="maxlength" value="30" />
   <set name="required" value="true" />
   <set name="immediate" value="true" />
  </attributes>
 </component>
 <component jsfid="firstNameMessage" extends="baseMessage">
  <attributes>
    ;<set name="for" value="firstName" />
  </attributes>
 </component>
 
 <component jsfid="basicPersonNamePanel" extends="panelGrid">
  <attributes>
   <set name="columns" value="3" />
  </attributes>
  <element renderId="22" jsfid="firstNameLabel" />
  <element renderId="24" jsfid="firstName" />
  <element renderId="26" jsfid="firstNameMessage" />
  <element renderId="42" jsfid="lastNameLabel" />
  <element renderId="46" jsfid="lastName" />
  <element renderId="48" jsfid="lastNameMessage" />
 </component>

 <component jsfid="fullPersonNamePanel"
  extends="basicPersonNamePanel">
  <element renderId="10" jsfid="namePrefixLabel" />
  <element renderId="14" jsfid="namePrefix" />
  <element renderId="16" jsfid="space" />
  <element renderId="30" jsfid="middleNameLabel" />
  <element renderId="34" jsfid="middleName" />
  <element renderId="36" jsfid="space" />
  <element renderId="50" jsfid="nameSuffixLabel" />
  <element renderId="54" jsfid="nameSuffix" />
  <element renderId="56" jsfid="space" />
 </component>
 
 <component jsfid="businessPersonNamePanel"
  extends="fullPersonNamePanel">
  <element renderId="-3" jsfid="businessNameLabel" />
  <element renderId="-2" jsfid="businessName" />
  <element renderId="-1" jsfid="space" />
 </component>
 
This snippet was taken form the shale-clay-usecases exmaple. 
 
Clay also has something we call symbols.  The value attributes in the
inputText widgets above contain a symbol, "@managed-bean-name",
that will be replaced to reflect the backing bean.  Symbols are a substation
layer that is evaluated before the value binding expressions are evaluated.
This allows you to create a dictionary of reusable view compositions that
can be plugged into various pages. 

In a JSP or HTML template, you might use the above person pannels
like the following:
 
 <h1>Basic Person</h1>
 <hr>
 <clay:clay id="basicPerson" clayJsfid="basicPersonNamePanel"
  managedBeanName="basicPerson" />
 <br>
 <h1>Full Person</h1>
 <hr>
 <clay:clay id="fullPerson" clayJsfid="fullPersonNamePanel"
  managedBeanName="fullPerson" />
 <br>
 <h1>Business Person</h1>
 <hr>
 <clay:clay id="businessPerson" clayJsfid="businessPersonNamePanel"
  managedBeanName="businessPerson" />
 <br>
 
 
>regards
>Matthias
 
 
Gary

Reply via email to