>If a have a shared html template how can I parameterize component ids
>such that the template can be used more than once within the view?
>
>For example, if I have a
>
><input id="myField" jsfid="inputText" type="text" value="@binding"/>
>
>within a reusable template, and I used the template twice in a view, I
>would get an error because the of duplicate ids in the faces tree.
>
>can I simply change to
>
><input id="@id" jsfid="inputText" type="text" value="@binding"/>
>
>in the template and specify two different @ids in the template client
>to resolve this?
>
>better yet can I change to
>
><input id="@idPrefixMyField" jsfid="inputText" type="text" value="@binding"/>
>
>and specify 1 @idPrefix so that I can have multiple <input>s within
>the template and still be okay? Like
>
><input id="@idPrefixMyField" jsfid="inputText" type="text" value="@binding"/>
>
><input id="@idPrefixMyField2" jsfid="inputText" type="text" value="@binding2"/>
>
>I ask this only because I think in the past the jsfid id was handled
>differently than
>other attributes (for example the symbol replacement happenend after
>the value was bound to the component).
>
>Just wanted to make sure that the id symbol replacement will happen
>before binding to the component.
>


You can totally do this kind of thing.  The shale-clay-usecases (in the sand 
box) 
shows and example found under symbols.  The page3 link shows a small template 
that is included for all fields on the page. 

The id attribute was originally static but now allows for symbol replacement 
(that might have even been your idea Rynn :-).

Here's a few more variations on the symbol example. The outer template looks 
like this:

 <tr
  jsfid="classpath*:org/apache/shale/usecases/symbols/inputTextWidget.html"
  label="First Name:" property="firstName" size="20" maxlength="30"
  required="true" immediate="false" />
 <tr
  jsfid="classpath*:org/apache/shale/usecases/symbols/inputTextWidget.html"
  label="Middle Name:" property="middleName" size="20" maxlength="30"
  required="false" immediate="false" />

It could be changed to something like this:
<tr>
   <td><label jsfid="outputLabel" for="@property" value="@label" 
allowBody="false">Mock Label:</label></td>
   <td><input id="@property" jsfid="inputText" type="text" size="@size" 
maxlength="@maxlength" 
              required="@required" immediate="@immediate"/></td>
   <td><span for="@property" jsfid="message" allowBody="false">Mock 
Message</span><td>
</tr>

Or, you could wrapper it in a subview and make the id's the same.  You'd never 
actually 
do this but it's still fun.
<span jsfid="subview">
  <tr>
     <td><label jsfid="outputLabel" for="id" value="@label" 
allowBody="false">Mock Label:</label></td>
     <td><input id="id" jsfid="inputText" type="text" size="@size" 
maxlength="@maxlength" 
              required="@required" immediate="@immediate"/></td>
     <td><span for="id" jsfid="message" allowBody="false">Mock 
Message</span><td>
  </tr>
</span>
>
>
>Thanks,
>Ryan

Gary

Reply via email to