Re: Help with a design issue that I'm stumped by....
Vic Cekvenich <[email protected]> Tue, 27 May 2003 11:16:41 -0400
| Newsgroups | gmane.comp.java.mvc.devel |
|---|---|
| Organization | baseBeans Engineering |
| Message-ID | <[email protected]> |
Actually, the search bean can just be a regular Struts form bean... you
are right. :-[
More coffee please.
.V
Vic Cekvenich wrote:
> Read my other post on search. (The first one... excuse my ADD).
>
> Please let me understand why you think it wiered.
> Search has bean, action, form.
> You submit search to the action, with search bean populated. (not much
> use for a basebean code here, I think you are saying)
>
> ListEmployees has a page, action, bean.
> It needs to receive in (session?) scope (or url properites) the search
> arguments in the action only.
> based on it, it populates the bean and page displays it.
>
> ..V
>
> Rick Reumann wrote:
>
>>On Tue, 27 May 2003 09:57:33 -0400, Vic Cekvenich wrote:
>>
>>
>>
>>>Struts does this for you. On a submit, all the bean properties are set
>>>by Struts before the action gets executed. There is not new bean, since
>>>it's in scope already.
>>>
>>>
>>
>>Yes, normally it does. But remember all of this is complicated by this
>>"search" that I'm talking about. Remember I'm trying to get a list backed
>>bean based on certain search criteria (WHERE parameters). The idea you
>>helped me come up with was this pattern....
>>
>>(For this example using "ProjectBean" and "ProjectSearchBean"...)
>>
>>/projectSearch backed by ProjectSearchBean forwards the user to a a JSP
>>Form where they select paramaters that they want to get a list of Projects
>>back for.
>>
>>Submitting above form ends up forwarding to the ProjectAdminAction with
>>Dispatch "Display"
>>
>>In the onDisplayExec method of ProjectAdminAction I then have to pull the
>>ProjectSearchBean out of session scope and then can pull out the search
>>params..
>>
>>ProjectSearchBean searchBean =
>>(ProjectSearchBean)ae.getSessionBean("projectSearchBean");
>>ArrayList projectIds = projectSearchBean.getProjectIds();
>>String someOtherVar = projectSearchBean.getSomeOtherVar();
>>
>>//now populate based on search params above
>>projectFormBean.populate( projectIds, someOtherVar );
>>
>>The above seems to be what you mentioned is the best way to handle this
>>type of search feature. What is happening here is much different than the
>>typical save, update type of procedure that you can call ProjectBean. I
>>understand how that's all done. This is much different since the above
>>properties are necessarily part of ProjectBean, they are simply properties
>>used to create the WHERE portion for bring back the ProjectBean list.
>>
>>At some point later I end up putting the above variables projectIds and
>>someOtherVar into a HashMap in the ProjectBeanDAO so I can pass that to
>>IBatis. It works fine but it just seems a bit cumbrsome to pull all the
>>values out of the ProjectSearchBean and then put them back into some
>>storage object (in this case HashMap).
>>
>>Since ProjectSearchBean is a BaseBean, should I maybe just call:
>>projectFormBean.populate( searchBean.getMap() )
>>?
>>
>>It just seems weird to take everything out of the BaseBean in order to
>>call populate( var, var, var), only to rebuild it all again into an object
>>in the DAO so that I can call
>>doRetrieve("ProjectSelect", (Object)map );
>>
>>
>>
>>
>>>It says in iBatis DOCs how iBatis processes a "custom" SQL parm. You can
>>>need to create the SQL ending dynamically. It's done a lot on search
>>>screens, dynamic WHERE.
>>>
>>>
>>
>>Thanks...found it. Awesome.
>>
>>
>>
>
>--
>Vic Cekvenich,
>Struts Instructor,
>1-800-917-JAVA
>
>Advanced <a href ="baseBeans.com">Struts Training</a> and project recovery in North East.
>Open Source <a href ="baseBeans.com">Content Management</a> basicPortal sofware
>Best practice<a href ="baseBeans.com">Struts Support</a> v.1.1 helper ScafflodingXPress
>
>
>
--
Vic Cekvenich,
Struts Instructor,
1-800-917-JAVA
Advanced <a href ="baseBeans.com">Struts Training</a> and project recovery in North East.
Open Source <a href ="baseBeans.com">Content Management</a> basicPortal sofware
Best practice<a href ="baseBeans.com">Struts Support</a> v.1.1 helper ScafflodingXPress