cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastien Arbogast <sebastien.arbog...@gmail.com>
Subject Re: [CForms] Getting selectedValues from a multivaluefield ?
Date Mon, 23 May 2005 16:56:16 GMT
2005/5/23, Johannes Textor <jc.textor@gmx.de>:
> 
> >Please help ! I tried to find a solution in samples but the only
> >multivaluefield I found was not used from flowscript. The whole form
> >is just forwarded to some XSP logicsheet as a request parameter.
> >
> >
> >
> Maybe you cannot pass the model.userRoles directly. Keep in mind that
> the flowscript form binding is designed to work from JavaScript, not
> Java. I'm using a loop to feed the values to my Hibernate Object like this:
> 
> *if*(model.rubriken.length>0)
> {
> *       for*( *var* i = 0 ; i < model.rubriken.length; i++ )
>                 artikel.getRubriken().add(hs.load(Rubrik,*new* java.lang.Long(model.rubriken[i])));
> }
> 
> hs is the Hibernate Session which I'm using from flowscript, but never
> mind. The problem is that there is no way I'm aware of to create native
> Java Arrays in flowscript (because JavaScript Arrays are really a different
> type of object !) The only solution I can think of is to refactor your
> createUser method to accept a Vector of objects rather than a String[],
> and then do:
> 
>     model = form.getModel();
> 
>     var roles = new java.util.Vector();
> 
>     for( var i = 0 ; i < model.userRoles.length ; i ++ )
>         roles.add( new java.lang.String( model.userRoles[i] ) );
> 
>     user = schaman.createUser(
>         model.userName,
>         DigestUtils.md5Hex(model.password),
>         model.userActive,
>         model.userEmail,
>         roles
>     );
> 
> Yes I know it's ugly, can somebody come up with a better solution ? Because
> I've had exactly the same problem and could not come up with a better
> solution
> than the one described above. But maybe that is because CForms is designed
> to be smoothly used from JavaScript, and I found the conversion between
> JavaScript
> and Java painful at times.
> 

Thank you very much for your help Johannes. In a way this reassures me
because I'm not alone with that problem. Actually I already have a
addRole method and I'll use it as you suggest.
Otherwise I guess the problem doesn't occur in javaflow but I have
absolutely no idea how to use it so...

-- 
Sebastien ARBOGAST

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message