commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rodrigo Partearroyo <jtbpa...@aintel.bi.ehu.es>
Subject Re: [Betwixt] Customizing Vector binding with dot betwixt file
Date Mon, 05 Sep 2005 09:56:35 GMT
Thank for your response Robert, i´ve been on vacations till today. I'll
try your solution.

robert burrell donkin wrote:
> On Tue, 2005-07-26 at 18:25 +0200, Rodrigo Partearroyo wrote:
> 
>>I´m trying to serialize a Vector of Strings. They are the security-roles
>>allowed to access some part of my webapp. The output i need is this:
>>
>><security-roles>
>>    <security-role rol="rol1" />
>>    <security-role rol="rol2" />
>>    <security-role rol="rol3" />
>>    <security-role rol="rol4" />
>></security-roles>
>>
>>but all i can obtain is this:
>>
>><security-roles>
>>    <security-role rol="[rol1, rol2, rol3, rol4]"/>
>></security-roles>
>>
>>The bean i'm using is :
>>
>>public class SecurityRolesBean {
>>    private Vector rolesList;
>>    public SecurityRolesBean (){
>>        rolesList = new Vector();
>>    }
>>    public Vector getRolesList(){
>>        return rolesList;
>>    }
>>    public void setServiceRole(String role){
>>        setRolesList(role);
>>    }
>>    private void setRolesList(String rol){
>>        rolesList.addElement(rol);
>>    }
>>}
>>
>>and the dot betwixt file:
>>
>><?xml version="1.0"?>
>><info>
>>    <element name="security-roles">
>>    <element name="security-role">
>>        <attribute name='rol' property='rolesList'/>
>>    </element>
>>    </element>
>></info>
>>
>>The question is: How can i put each of the Vector's elements (which are
>>Strings) in separate xml elements?
> 
> 
> that 'attribute' tag needs to be an 'element' tag 
> 
> <?xml version="1.0"?>
> <info>
>     <element name="security-roles">
>     <element name="security-role">
>         <element name='rol' property='rolesList'/>
>     </element>
>     </element>
> </info>
> 
>>The inverse step (populating the Bean with data read from a xml file) is
>>done with Digester following this rule:
>>
>>[...]
>><pattern value="security-role">
>>    <set-properties-rule>
>>        <alias attr-name="rol" prop-name="serviceRole" />
>>    </set-properties-rule>
>></pattern>
>>[...]
>>
>>Due to Digester cannot perform the inverse operation (writting beans to
>>xml files) i´m trying to move it to Betwixt, but the xml format cannot
>>change.
> 
> 
> betwixt should handle this pretty easily. you'll need to add the name of
> the adder to be used to the dot betwixt file 
> 
> <?xml version="1.0"?>
> <info>
>     <element name="security-roles">
>     <element name="security-role">
>         <element name='rol' property='rolesList' adder='setServiceRole'/>
>     </element>
>     </element>
> </info>
> 
> please take a look at the documentation
> (http://jakarta.apache.org/commons/betwixt) for more details.
> 
> - robert
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 

-- 
Rodrigo Partearroyo González

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message