You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rick Reumann <ma...@reumann.net> on 2002/07/11 17:02:42 UTC

Should I bother to try and handle this with struts?

I'm confused how I can/should handle this in Struts...

What I need to build (and long story why) is a User Administration
utility and where I'm having trouble fitting this in with struts is in
regard to the following:

Picture a case where you want to give user's certain roles based on
certain applications. So you'd have:

BackofficeApp    [ select options of possible roles ]
JoeBlowApp       [ select options of possible roles ]
DumbApp          [ select options of possible roles ]

The problem is the list of applications is dynamic so I can't hard
code these values into a form bean or in my dynamicActionForm.

Currently I'm planning on doing this an old fashioned way where after
submission I'll loop through the same dynamic list of applications and
pull up the request parameters based on the values I get back. So for
example somewhere I'd end up doing:

//while loop through applications
String appValue = request.getParameter( appNameBasedOnCurrentLoopValue );
       //update db for this app name based on value
//continue loop

Can I have a form bean gather all this data? Or should I just continue
to do it the way I'm doing it?

Thanks for any comments/help.



-- 

Rick
mailto:maillist@reumann.net


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Should I bother to try and handle this with struts?

Posted by Eddie Bush <ek...@swbell.net>.
Please note that I have not used the items I am about to tell you about 
:-)  That having been said:

DynaForms - from what I understand, they will "suck up" anything and 
poke it in a hash.  I'm not sure whether you could use this - or maybe 
DynaBeans - but, from my (limited) understanding of them, I think you 
probably could.  Internally, as I said, they poke things into a hash. 
 Now ... hrm ... I need to catch up on the new Struts features :-)

I really think you can acheive this.  To get someone elses attention, 
post a new topic about "Help with DynaBeans/DynaForms".  That's nearly 
certain to get someone's attention.

HTH,

Eddie

Rick Reumann wrote:

>On Thursday, July 11, 2002, 12:22:57 PM, Eddie wrote:
>
>EB> Use container-managed authentication.
>
>Eddie, thanks for your info on container management but actually my
>question really isn't about how to manage authentication. (I should
>have been more clear).
>
>It is how do you use Struts to generate form field names that will be
>generated dynamically and then later have access to them to using an
>Action Form or a configured Dynamic Action Form.
>
>Let's change the whole scenario around and say I'm creating a page
>that has a list of items and you have to select the favorite color of
>each. For example:
>
>car    [ select options of colors to choose ]
>house  [ select options of colors to choose ]
>sofa   [ select options of colors to choose ]
>
>Now the problem is that the items are generated dynamically so that
>the application doesn't know until run time what these items will be.
>
>Is there a way to have a Struts Action Form manage gather this kind of
>information.
>
>I was hoping to avoid when the above form would submit having to do
>this in some business object using the request object:
>
>//get List from db
>//loop through list and during each iteration:
>       String colorValue = request.getParameter( itemInList );
>       //now update db with this value for this item
>//continue loop
>
>Maybe I have no choice. I'm just not clear how I can use a Struts form
>to capture this dynamic list of items, since I can't configure the
>fields beforehand.
>
>Thanks for any more help
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re[2]: Should I bother to try and handle this with struts?

Posted by Rick Reumann <ma...@reumann.net>.
On Thursday, July 11, 2002, 12:22:57 PM, Eddie wrote:

EB> Use container-managed authentication.

Eddie, thanks for your info on container management but actually my
question really isn't about how to manage authentication. (I should
have been more clear).

It is how do you use Struts to generate form field names that will be
generated dynamically and then later have access to them to using an
Action Form or a configured Dynamic Action Form.

Let's change the whole scenario around and say I'm creating a page
that has a list of items and you have to select the favorite color of
each. For example:

car    [ select options of colors to choose ]
house  [ select options of colors to choose ]
sofa   [ select options of colors to choose ]

Now the problem is that the items are generated dynamically so that
the application doesn't know until run time what these items will be.

Is there a way to have a Struts Action Form manage gather this kind of
information.

I was hoping to avoid when the above form would submit having to do
this in some business object using the request object:

//get List from db
//loop through list and during each iteration:
       String colorValue = request.getParameter( itemInList );
       //now update db with this value for this item
//continue loop

Maybe I have no choice. I'm just not clear how I can use a Struts form
to capture this dynamic list of items, since I can't configure the
fields beforehand.

Thanks for any more help

-- 
Rick

EB> Rick Reumann wrote:

>>I'm confused how I can/should handle this in Struts...
>>
>>What I need to build (and long story why) is a User Administration
>>utility and where I'm having trouble fitting this in with struts is in
>>regard to the following:
>>
>>Picture a case where you want to give user's certain roles based on
>>certain applications. So you'd have:
>>
>>BackofficeApp    [ select options of possible roles ]
>>JoeBlowApp       [ select options of possible roles ]
>>DumbApp          [ select options of possible roles ]
>>
>>The problem is the list of applications is dynamic so I can't hard
>>code these values into a form bean or in my dynamicActionForm.
>>
>>Currently I'm planning on doing this an old fashioned way where after
>>submission I'll loop through the same dynamic list of applications and
>>pull up the request parameters based on the values I get back. So for
>>example somewhere I'd end up doing:
>>
>>//while loop through applications
>>String appValue = request.getParameter( appNameBasedOnCurrentLoopValue );
>>       //update db for this app name based on value
>>//continue loop
>>
>>Can I have a form bean gather all this data? Or should I just continue
>>to do it the way I'm doing it?
>>
>>Thanks for any comments/help.
>>
>>
>>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Should I bother to try and handle this with struts?

Posted by Eddie Bush <ek...@swbell.net>.
Use container-managed authentication.  For your role names, prepend a 
unique identifier for the application:

BackOfficeApp Roles:
   BOA_USER
   BOA_ADMIN

JoeBlowApp Roles:
   JBA_USER
   JBA_ADMIN

DumbApp Roles:
   DAP_USER
   DAP_ADMIN

I think that covers your needs, doesn't it?

You could then, additionally, through the container or the web-app 
deployment descriptor, specify what the role name prefix is for the 
application and use that information, combined with standard method 
calls, to determine who should see what.

If you're using Tomcat, but you're not currently using container-managed 
authentication - AND you're going to keep these folks in a database - 
take a look at the JDBCRealm.  You can also do LDAP (though I have no 
experience using it) with the JNDIRealm.  These (as well as the 
MemoryRealm - flat-file configuration - not good if you need to update 
dynamically and have it immediately visible) are "not too hard" to 
setup.  Plus, rather than having to code some "search" algorithm (ack! 
why?!  only if you have special needs is this required - the solution 
above does not qualify as a "special need"), you can make use of the 
(tried and true!) code-base that already exists in the JDK for 
determining who is in what role(s).

Container-managed Authentication == Goooooooooooooooooooooood

Also, using Tomcat (I can't speak for other servers because I only use 
TC :-P), you can configure the realm to be there for a context, a 
(virtual) host, or an entire server.  It gives you a great deal of control.

HTH,

Eddie

Rick Reumann wrote:

>I'm confused how I can/should handle this in Struts...
>
>What I need to build (and long story why) is a User Administration
>utility and where I'm having trouble fitting this in with struts is in
>regard to the following:
>
>Picture a case where you want to give user's certain roles based on
>certain applications. So you'd have:
>
>BackofficeApp    [ select options of possible roles ]
>JoeBlowApp       [ select options of possible roles ]
>DumbApp          [ select options of possible roles ]
>
>The problem is the list of applications is dynamic so I can't hard
>code these values into a form bean or in my dynamicActionForm.
>
>Currently I'm planning on doing this an old fashioned way where after
>submission I'll loop through the same dynamic list of applications and
>pull up the request parameters based on the values I get back. So for
>example somewhere I'd end up doing:
>
>//while loop through applications
>String appValue = request.getParameter( appNameBasedOnCurrentLoopValue );
>       //update db for this app name based on value
>//continue loop
>
>Can I have a form bean gather all this data? Or should I just continue
>to do it the way I'm doing it?
>
>Thanks for any comments/help.
>
>
>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>