I agree about littering action beans but what about integration testing?  
Suppose you want to replace ComponentListActionBean with a stub or fake that 
exercises corner cases that you need to test?  Then in your tests instead of 
ComponentManager you could inject into your action beans 
MisbehavingComponentManager.
 

Mike McNally wrote:
> jsp:useBean seems pretty useful to me.  In a real web application,
> there are all sorts of contextual things that are important to the
> application (and the presentation of application status, situations,
> context, etc) that span many separate pages (and therefore actions).
> Having to litter lots of action beans with code to fetch random pieces
> of utility content for page layout (say, user address/phone
> information) seems like a real mess, while having dedicated beans that
> can be pulled into the Request via dedicated tags is pretty easy and
> clean. The bean contents can be referenced from EL expressions, used
> in things like Stripes options-collection tags, etc.  If the
> application has some sort of per-thread context, then the beans should
> need no parameters after instantiation.
> 
> My application has several such beans, and honestly I can't think of
> any downsides.
> 
> 
> On Thu, Sep 24, 2009 at 2:27 PM, Iwao AVE! <haraw...@gmail.com> wrote:
>> I also don't use <jsp:useBean />, but in this case, I would use
>> <stripes:useActionBean /> within a JSP tag file:
>>
>> [optionsComponent.tag]
>>
>> <stripes:useActionBean
>>  var="componentListBean"
>>  beanclass="ComponentListActionBean" />
>> <stripes:options-collection
>>  collection="${componentListBean.allComponents}"
>>  label="name" value="id"/>
>>
>> You will have to create the new ComponentListActionBean, but this
>> saves you from defining the 'allComponent' property and its getter
>> in every action bean that needs to display the drop-down list.
>> And in any JSP in the webapp, you can use the tag without modifying
>> the main action bean:
>>
>> <stripes:select name="bug.component.id">
>> <tags:optionsComponent />
>> </stripes:select>
>>
>> --
>> Actually, there is no advantage of using <stripes:useActionBean />
>> over <jsp:useBean /> in the above example, but
>> <stripes:useActionBean /> allows you to
>>
>> 1) access session attributes or context resources in its logic.
>>
>> 2) reuse the same action bean for returning the same list in various
>> formats (json, xml, etc.) quite easily.
>>
>> --
>> Another option is to use <jsp:include /> in the tag file, but it
>> will cause performance loss in the bulk edit page.
>>
>> Regards,
>> Iwao
>>
>>
>> on 09/09/24 19:41 Freddy Daoud said the following:
>>> Hi Rusty,
>>>
>>>> Some of the jsps use jsp:useBean to pull in beans from the service layer.
>>>> [...]
>>>> The way I've done it in the past would be to have a property on the
>>>> action bean, allComponents for example, with its getter, and to call
>>>> componentManager.allComponents() in the action bean to set the
>>>> allComponents property.
>>> I agree. That's how I prefer to do this as well.
>>>
>>> Personally, I try to avoid<jsp:useBean>  and I think<s:useActionBean>
>>> should be deprecated. I can't think of a situation where there isn't
>>> another (better) way to get things done than with<s:useActionBean>.
>>> If anyone has a good use case, please share.
>>>
>>> Cheers,
>>> Freddy
>>> http://www.stripesbook.com
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> Stripes-users mailing list
>> Stripes-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
> 
> 
> 

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to