struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gvanma...@comcast.net (Gary VanMatre)
Subject Re: [shale] Extending components with new attributes
Date Tue, 07 Mar 2006 00:21:22 GMT

>From: Richard Wallace <rwallace@thewallacepack.net> 
>
> Hello, 
> 
> I'd like to extend the inputSecret component and give the new component 
> an added attribute. Basically, what I want to do is create a component 
> that has the tomahawk equal validator attached to it. So, what I've got 
> now is: 
> 
>
><view>
>  <component jsfid="t:validateEqual" 
>componentType="org.apache.myfaces.validator.Equal">
>    <attributes>
>      <set name="for" bindingType="Early" />
>    </attributes>
>  </component>
> 
>  <component jsfid="inputPasswordVerification" extends="inputSecret">
>    <validator jsfid="t:validateEqual">
>      <attributes>
>          <set name="for" value="password"/>
>      </attributes>
>    </validator>
>  </component>
></view>
>
> 
> What I'd like to be able to do is replace the attribute for "for" with 
> something more like "@for" or something so that I can use the component 
> like: 
> 
><input type="password" jsfid="inputSecret" id="password" />
><input type="password" jsfid="inputPasswordVerification" for="password" />
>
> Can I add an attribute like that in clay? That would be very cool. 
> 


You should totally be able to do this using Clay.  There is a very similar example in the
symbols (symbols/page3.html) usecases.  There's one more layer than you need in your example.

Includes an html template from the class path passing symbols label, property, size, maxlenght,
required and immediate.
    <tr jsfid="classpath*:org/apache/shale/usecases/symbols/inputTextWidget.html" label="First
Name:" 
        property="firstName" size="20" maxlength="30" 
        required="true" immediate="false"/>

The "org/apache/shale/usecases/symbols/inputTextWidget.html" template is used for layout.
 It's bound to some base XML config data.
<tr>
   <td><label jsfid="widgetsLabel">Mock Label:</label></td>
   <td><input jsfid="widgetsText" type="text"/></td>
   <td><span jsfid="widgetsMessage">Mock Message</span><td>
</tr>

The base config definitions are defined in "WEB-INF/clay-symbols-config.xml"
        <component jsfid="widgetsLabel" extends="baseLabel"> 
     <attributes>
     <set name="value" value="@label" />  
     <set name="for"   value="@property" />
     </attributes>
 </component>    
 <component jsfid="widgetsText" extends="inputText" id="@property"> 
     <attributes>
        <set name="value" value="#{@managed-bean-name.@property}"/>  
     <set name="size" value="@size" />
     <set name="maxlength" value="@maxlength" />
     <set name="required" value="@required" />
     <set name="immediate" value="@immediate"/>
     </attributes>
 </component>
 <component jsfid="widgetsMessage" extends="baseMessage" > 
     <attributes>
        <set name="for" value="@property" />  
     </attributes>
 </component>


> Thanks, 
> Rich 

Gary

> 
> --------------------------------------------------------------------- 
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org 
> For additional commands, e-mail: user-help@struts.apache.org 
> 
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message