You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Micael <ca...@harbornet.com> on 2003/05/24 00:39:14 UTC
PlugIns and Getter Methods
I would normally use the following JSP code, outside a Struts environment.
<% com.mysite.user.UserServicePlugIn plugger =
(com.mysite.user.UserServicePlugIn)session.getAttribute(UserServicePlugIn.UserService);
%>
<%= plugger.getApplications() %>
I am trying to do this the Struts way, which I support, actually. But,
<bean:write name='user_service' property='applications' /> results in an
exception say that there is no getter method for the property
applications. The code plugger.getApplications() returns a ListHandler
that has two fields, a List and a ListIteratorVO, for manipulating the
values in the List object. Does the object returned have to actually be
called "applications" in the UserServicePlugIn class?
The code in UserServicePlugIn to get the ListHandler is:
public static ListHandler getApplications()
throws ChainedException {
ApplicationDAO applicationDAO = daoFactory.getApplicationDAO();
Collection applications = applicationDAO.selectApplicationsVO();
ListHandler listHandler = new ListHandler();
listHandler.setList((List)applications);
return listHandler;
}
I am using Struts 1.1 with Tomcat 4.1.18.
Thanks for any assistance.
Micael
LEGAL NOTICE
This electronic mail transmission and any accompanying documents contain
information belonging to the sender which may be confidential and legally
privileged. This information is intended only for the use of the
individual or entity to whom this electronic mail transmission was sent as
indicated above. If you are not the intended recipient, any disclosure,
copying, distribution, or action taken in reliance on the contents of the
information contained in this transmission is strictly prohibited. If you
have received this transmission in error, please delete the message. Thank you
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: PlugIns and Getter Methods
Posted by Ted Husted <hu...@apache.org>.
Generally, it would be simplest to have the Action expose your PlugIn as
a ordinary bean. You can make direct references to it using tags, but
the "Struts Way" would be to have the Action place whatever you page
"needs to know" into request scope, where it will be easy to find. If
the page just needs the collection from the list handler, then that's
what the Action should expose. This way, if you change how your PlugIn
works later, you do not have to change the pages, only the Action.
Many problems people have with pages can often be solved by letting the
Action or ActionForm simplify the problem, so that the tags do have to
work so hard. In a MVC application, the pages should just be able to
render data in the simplest form possible, without worrying about where
it comes from.
-Ted.
Micael wrote:
> I would normally use the following JSP code, outside a Struts environment.
>
> <% com.mysite.user.UserServicePlugIn plugger =
> (com.mysite.user.UserServicePlugIn)session.getAttribute(UserServicePlugIn.UserService);
> %>
> <%= plugger.getApplications() %>
>
> I am trying to do this the Struts way, which I support, actually. But,
> <bean:write name='user_service' property='applications' /> results in an
> exception say that there is no getter method for the property
> applications. The code plugger.getApplications() returns a ListHandler
> that has two fields, a List and a ListIteratorVO, for manipulating the
> values in the List object. Does the object returned have to actually be
> called "applications" in the UserServicePlugIn class?
>
> The code in UserServicePlugIn to get the ListHandler is:
>
> public static ListHandler getApplications()
> throws ChainedException {
>
> ApplicationDAO applicationDAO = daoFactory.getApplicationDAO();
> Collection applications = applicationDAO.selectApplicationsVO();
> ListHandler listHandler = new ListHandler();
>
> listHandler.setList((List)applications);
>
> return listHandler;
> }
>
> I am using Struts 1.1 with Tomcat 4.1.18.
>
> Thanks for any assistance.
>
> Micael
>
>
> LEGAL NOTICE
>
> This electronic mail transmission and any accompanying documents
> contain information belonging to the sender which may be confidential
> and legally privileged. This information is intended only for the use
> of the individual or entity to whom this electronic mail transmission
> was sent as indicated above. If you are not the intended recipient, any
> disclosure, copying, distribution, or action taken in reliance on the
> contents of the information contained in this transmission is strictly
> prohibited. If you have received this transmission in error, please
> delete the message. Thank you
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
--
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org