You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Caroline Jen <ji...@yahoo.com> on 2004/10/22 18:02:39 UTC

Need Ideas for This Puzzle

The puzzle relates to displaying check boxes (checkbox
or multibox).

What I have are members who belong to professional
groups and sub-groups.  E.g.,

Group A with sub-groups A-1, A-2, A-3, A-4.
Group B with sub-groups B-1, B-2, B-3
Group C with sub-groups C-1, C-2, C-3, C-4, C-5, C-6
etc.

web site users make multiple selections among groups. 
And all members in those groups will receive an e-mail
message.

I can display a check box for every single
"sub-group".  And give each "group" a "select all"
check box.  All I have to take care are the checked
"sub-groups".

The challege comes as the "roles" of the web site
users are introduced.  According to the role of the
web site user, I have to display certain groups (not
all the groups) and certain sub-groups (not all
sub-groups within a group) to him/her.

How do I disply groups and their sub-groups under such
a condition?





		
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo 

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


Re: Need Ideas for This Puzzle

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
There are at least two good solutions.  I like the second one best.


1.  Tag Conditional Logic Solution

Just use the <c:if>, <c:choose> and <c:when> tags.  I assume, Caroline, 
that you are using JSTL.  If not, then there are equivalent solutions 
with Struts logic tags.


2  Action Conditional Delivery Solution

Or, you can read the role of the user going into the Action that 
forwards to the response object displaying the options and only deliver 
the options appropriate to the role of the user. 


Michael McGrady
 


 

Caroline Jen wrote:

>The puzzle relates to displaying check boxes (checkbox
>or multibox).
>
>What I have are members who belong to professional
>groups and sub-groups.  E.g.,
>
>Group A with sub-groups A-1, A-2, A-3, A-4.
>Group B with sub-groups B-1, B-2, B-3
>Group C with sub-groups C-1, C-2, C-3, C-4, C-5, C-6
>etc.
>
>web site users make multiple selections among groups. 
>And all members in those groups will receive an e-mail
>message.
>
>I can display a check box for every single
>"sub-group".  And give each "group" a "select all"
>check box.  All I have to take care are the checked
>"sub-groups".
>
>The challege comes as the "roles" of the web site
>users are introduced.  According to the role of the
>web site user, I have to display certain groups (not
>all the groups) and certain sub-groups (not all
>sub-groups within a group) to him/her.
>
>How do I disply groups and their sub-groups under such
>a condition?
>
>
>
>
>
>		
>__________________________________
>Do you Yahoo!?
>Take Yahoo! Mail with you! Get it on your mobile phone.
>http://mobile.yahoo.com/maildemo 
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>  
>



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


[OT]: Need Ideas for This Puzzle

Posted by DG...@EvergreenInvestments.com.
Maybe it's because it's Friday, or maybe it's because I've been especially 
dense this week, but isn't multithreading orthogonal to the problem?

Dennis





Michael McGrady <mi...@michaelmcgrady.com> 
10/22/2004 02:05 PM
Please respond to
"Struts Users Mailing List" <us...@struts.apache.org>


To
Struts Users Mailing List <us...@struts.apache.org>
cc

Subject
Re: Need Ideas for This Puzzle






Hi, Caroline,

Just a little follow up to all these good suggestions.  I agree that if 
you use the Action, then you should definitely use helper classes and 
hopefully decouple them from the action.  I like to use multithreading 
in the helper classes generally.  The suggestions about using the 
ActionForm instead are also good.  I guess to decide whether you want to 
go with Action or ActionForm should depend on whether your logic makes 
the choice of roles one of presentation or one of buisness logic.  I 
think it could go either way.  Definitely these are two different 
approaches.

Michael McGrady


Wendy Smoak wrote:

>From: "Caroline Jen" <ji...@yahoo.com>
> 
>
>>The challege comes as the "roles" of the web site
>>users are introduced.  According to the role of the
>>web site user, I have to display certain groups (not
>>all the groups) and certain sub-groups (not all
>>sub-groups within a group) to him/her.
>>How do I disply groups and their sub-groups under such
>>a condition?
>> 
>>
>
>I would decide who sees what by calling helper classes from the Action, 
then
>only place objects in the request or session that the user is allowed to
>see.  That way by the time you get to the JSP all you have to do is 
iterate
>over what's there.
>
> 
>



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



Re: Need Ideas for This Puzzle

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
Hi, Caroline,

Just a little follow up to all these good suggestions.  I agree that if 
you use the Action, then you should definitely use helper classes and 
hopefully decouple them from the action.  I like to use multithreading 
in the helper classes generally.  The suggestions about using the 
ActionForm instead are also good.  I guess to decide whether you want to 
go with Action or ActionForm should depend on whether your logic makes 
the choice of roles one of presentation or one of buisness logic.  I 
think it could go either way.  Definitely these are two different 
approaches.

Michael McGrady


Wendy Smoak wrote:

>From: "Caroline Jen" <ji...@yahoo.com>
>  
>
>>The challege comes as the "roles" of the web site
>>users are introduced.  According to the role of the
>>web site user, I have to display certain groups (not
>>all the groups) and certain sub-groups (not all
>>sub-groups within a group) to him/her.
>>How do I disply groups and their sub-groups under such
>>a condition?
>>    
>>
>
>I would decide who sees what by calling helper classes from the Action, then
>only place objects in the request or session that the user is allowed to
>see.  That way by the time you get to the JSP all you have to do is iterate
>over what's there.
>
>  
>



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


Re: Need Ideas for This Puzzle

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Caroline Jen" <ji...@yahoo.com>
> The challege comes as the "roles" of the web site
> users are introduced.  According to the role of the
> web site user, I have to display certain groups (not
> all the groups) and certain sub-groups (not all
> sub-groups within a group) to him/her.
> How do I disply groups and their sub-groups under such
> a condition?

I would decide who sees what by calling helper classes from the Action, then
only place objects in the request or session that the user is allowed to
see.  That way by the time you get to the JSP all you have to do is iterate
over what's there.

-- 
Wendy Smoak


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


RE: Need Ideas for This Puzzle

Posted by Wiebe de Jong <wi...@shaw.ca>.
Keeping the unused fields around as hidden fields is a good idea. It will
keep your 'select all' javascript from getting complicated.

Just make sure that your action doesn't process any of the fields that were
made hidden, because hackers could modify those hidden fields manually
before sending back the response.

Wiebe

-----Original Message-----
From: Caroline Jen [mailto:jiapei_jen@yahoo.com] 
Sent: Friday, October 22, 2004 10:59 AM
To: Struts Users Mailing List
Subject: RE: Need Ideas for This Puzzle

What about something like:

<%
boolean checked = isChecked("a"); // check if the
value should be checked by default
if(showCheckbox(user, "a")) { // check if, for this
user, the checkbox should be visible
%>
<input type="checkbox" name="a" value="a" <%= checked
?"checked":"" %>>
<%
} else { // show disabled checkbox (or leave that out
to show nothing...)
%>
<input type="checkbox" name="noname" <%= checked ?
"checked" : "" %> disabled="diabled" />
<%
   if(checked) { // don't need hidden value if default
is unchecked
%>
<input type="hidden" name="a" value="a">
<%
   }
}
%>

--- Wiebe de Jong <wi...@shaw.ca> wrote:

> Here's my idea:
> 
> Create a bean that has multiple Boolean fields, with
> each corresponding to a
> checkbox you might want to display.
> 
> In the action that loads data for this page, process
> the user's role and set
> the bean's Boolean values accordingly. Store the
> bean so that the jsp can
> read it.
> 
> For all the checkboxes, the jsp will read the bean
> and display only the
> checkboxes that have a corresponding true value.
> 
> In the action that saves the data from this page,
> process only those
> checkboxes that were displayed.
> 
> Wiebe
> 
> -----Original Message-----
> From: Caroline Jen [mailto:jiapei_jen@yahoo.com] 
> Sent: Friday, October 22, 2004 9:03 AM
> To: struts-user@jakarta.apache.org
> Subject: Need Ideas for This Puzzle
> 
> The puzzle relates to displaying check boxes
> (checkbox
> or multibox).
> 
> What I have are members who belong to professional
> groups and sub-groups.  E.g.,
> 
> Group A with sub-groups A-1, A-2, A-3, A-4.
> Group B with sub-groups B-1, B-2, B-3
> Group C with sub-groups C-1, C-2, C-3, C-4, C-5, C-6
> etc.
> 
> web site users make multiple selections among
> groups. 
> And all members in those groups will receive an
> e-mail
> message.
> 
> I can display a check box for every single
> "sub-group".  And give each "group" a "select all"
> check box.  All I have to take care are the checked
> "sub-groups".
> 
> The challege comes as the "roles" of the web site
> users are introduced.  According to the role of the
> web site user, I have to display certain groups (not
> all the groups) and certain sub-groups (not all
> sub-groups within a group) to him/her.
> 
> How do I disply groups and their sub-groups under
> such
> a condition?
> 
> 
> 
> 
> 
> 		
> __________________________________
> Do you Yahoo!?
> Take Yahoo! Mail with you! Get it on your mobile
> phone.
> http://mobile.yahoo.com/maildemo 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 



		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

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


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


RE: Need Ideas for This Puzzle

Posted by Caroline Jen <ji...@yahoo.com>.
What about something like:

<%
boolean checked = isChecked("a"); // check if the
value should be checked by default
if(showCheckbox(user, "a")) { // check if, for this
user, the checkbox should be visible
%>
<input type="checkbox" name="a" value="a" <%= checked
?"checked":"" %>>
<%
} else { // show disabled checkbox (or leave that out
to show nothing...)
%>
<input type="checkbox" name="noname" <%= checked ?
"checked" : "" %> disabled="diabled" />
<%
   if(checked) { // don't need hidden value if default
is unchecked
%>
<input type="hidden" name="a" value="a">
<%
   }
}
%>

--- Wiebe de Jong <wi...@shaw.ca> wrote:

> Here's my idea:
> 
> Create a bean that has multiple Boolean fields, with
> each corresponding to a
> checkbox you might want to display.
> 
> In the action that loads data for this page, process
> the user's role and set
> the bean's Boolean values accordingly. Store the
> bean so that the jsp can
> read it.
> 
> For all the checkboxes, the jsp will read the bean
> and display only the
> checkboxes that have a corresponding true value.
> 
> In the action that saves the data from this page,
> process only those
> checkboxes that were displayed.
> 
> Wiebe
> 
> -----Original Message-----
> From: Caroline Jen [mailto:jiapei_jen@yahoo.com] 
> Sent: Friday, October 22, 2004 9:03 AM
> To: struts-user@jakarta.apache.org
> Subject: Need Ideas for This Puzzle
> 
> The puzzle relates to displaying check boxes
> (checkbox
> or multibox).
> 
> What I have are members who belong to professional
> groups and sub-groups.  E.g.,
> 
> Group A with sub-groups A-1, A-2, A-3, A-4.
> Group B with sub-groups B-1, B-2, B-3
> Group C with sub-groups C-1, C-2, C-3, C-4, C-5, C-6
> etc.
> 
> web site users make multiple selections among
> groups. 
> And all members in those groups will receive an
> e-mail
> message.
> 
> I can display a check box for every single
> "sub-group".  And give each "group" a "select all"
> check box.  All I have to take care are the checked
> "sub-groups".
> 
> The challege comes as the "roles" of the web site
> users are introduced.  According to the role of the
> web site user, I have to display certain groups (not
> all the groups) and certain sub-groups (not all
> sub-groups within a group) to him/her.
> 
> How do I disply groups and their sub-groups under
> such
> a condition?
> 
> 
> 
> 
> 
> 		
> __________________________________
> Do you Yahoo!?
> Take Yahoo! Mail with you! Get it on your mobile
> phone.
> http://mobile.yahoo.com/maildemo 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 



		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

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


RE: Need Ideas for This Puzzle

Posted by Wiebe de Jong <wi...@shaw.ca>.
Here's my idea:

Create a bean that has multiple Boolean fields, with each corresponding to a
checkbox you might want to display.

In the action that loads data for this page, process the user's role and set
the bean's Boolean values accordingly. Store the bean so that the jsp can
read it.

For all the checkboxes, the jsp will read the bean and display only the
checkboxes that have a corresponding true value.

In the action that saves the data from this page, process only those
checkboxes that were displayed.

Wiebe

-----Original Message-----
From: Caroline Jen [mailto:jiapei_jen@yahoo.com] 
Sent: Friday, October 22, 2004 9:03 AM
To: struts-user@jakarta.apache.org
Subject: Need Ideas for This Puzzle

The puzzle relates to displaying check boxes (checkbox
or multibox).

What I have are members who belong to professional
groups and sub-groups.  E.g.,

Group A with sub-groups A-1, A-2, A-3, A-4.
Group B with sub-groups B-1, B-2, B-3
Group C with sub-groups C-1, C-2, C-3, C-4, C-5, C-6
etc.

web site users make multiple selections among groups. 
And all members in those groups will receive an e-mail
message.

I can display a check box for every single
"sub-group".  And give each "group" a "select all"
check box.  All I have to take care are the checked
"sub-groups".

The challege comes as the "roles" of the web site
users are introduced.  According to the role of the
web site user, I have to display certain groups (not
all the groups) and certain sub-groups (not all
sub-groups within a group) to him/her.

How do I disply groups and their sub-groups under such
a condition?





		
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo 

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


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