The 'checked' attribute is also useful when it refers to a Collection.

In the Stripes book I show an example where you have a table with a list
of users, and one of the columns shows the roles that the user has. All
roles are rendered as checkboxes, and the ones that the user has are
checked by default. For that to work:

<c:forEach var="role" items="${actionBean.roles}"> <- all possible roles
  <s:checkbox name="users[${index}].roles" <- index is the current user
    value="${role}" checked="${user.roles}"/> <- list of roles the user
    has
  ${role}
</c:forEach>

Hope that helps.

Cheers,
Freddy

On Wed, Feb 8, 2012, at 09:53 PM, Iwao AVE! wrote:
> Hi,
> 
> Under the DefaultPopulationStrategy, 'checked' is used when there is
> no corresponding request parameter and the corresponding action bean
> property is null.
> 
> If your webapp uses BeanFirstPopulationStrategy and pre-actions,
> 'checked' will be ignored in most cases (please see doc *1).
> In this case, you will have to provide the default in action bean or
> somewhere if you want to check some checkboxes by default.
> 
> *1)
> http://stripes.sourceforge.net/docs/current/javadoc/net/sourceforge/stripes/tag/BeanFirstPopulationStrategy.html
> 
> Regards,
> Iwao
> 
> 2012/2/8 Chris Johnson <johns...@gmail.com>:
> > Can someone explain exactly when checkboxes are rendered checked..
> > I've done some playing around but it's still unclear to me how exactly
> > they should work:
> >
> > <stripes:checkbox name="item.id" value="A" checked="A"/> not checked ?
> > <stripes:checkbox name="item.id" value="A" checked="B"/> not checked ?
> >
> > The documentation says:  If the value of the checkbox is found to equal or 
> > be
> > contained by the 'checked' object then the checkbox will default to
> > rendering as checked.
> >
> > I find that if the value of the checkbox is found to be
> > equal to the value in name then the checkbox is checked..
> >
> > Can someone explain how i should be using this ?
> >
> > Thanks,
> > ..Chris
> >
> >
> >
> > ------------------------------------------------------------------------------
> > Keep Your Developer Skills Current with LearnDevNow!
> > The most comprehensive online learning library for Microsoft developers
> > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> > Metro Style Apps, more. Free future releases when you subscribe now!
> > http://p.sf.net/sfu/learndevnow-d2d
> > _______________________________________________
> > Stripes-users mailing list
> > Stripes-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/stripes-users
> 
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
> 

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to