struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kofford, C. Todd" <tkoff...@ku.edu>
Subject RE: Struts2 Portlet with Servlets
Date Sun, 23 Feb 2014 18:25:01 GMT
Yeah, below is a link to a simple example that we've been using for years. I originally started
with the code from one of the struts 2 examples, but changed the business objects to be more
interesting as well as other numerous changes. I just changed all the package names, so let
me know if you have problems, and I'll try to help.

https://dl.dropboxusercontent.com/u/25590011/struts2portlet.zip

We have several struts 2 webapps that run this way in production (standalone webapp &
portlet).

Also, we use the struts tags all over the place, and specifically the <s:url../> tag.
The cool thing about that tag is that it generates normal URLs for the standalone but portlet-specific
URLs for the portlet.

Todd Kofford
Academic Services Development
KU Information Technology
tkofford@ku.edu
(785) 864-0327

________________________________________
From: Gaurav Daga [togauravdaga@gmail.com]
Sent: Friday, February 21, 2014 12:07 PM
To: Struts Developers List
Subject: Re: Struts2 Portlet with Servlets

Hi Todd,

Thanks for your response. This sounds like, will do the work for me.  Do
you have any sample/demo app which can demonstrate the whole configuration?
 Also, how this configuration impacts behavior of Struts Tag library
specifically tags like <s:url.../>.  If you can share your experience
around it, please let me know.

Regards.


*Thanks & Regards/ **सादर**,*
*Gaurav Daga*
*togauravdaga@gmail.com <togauravdaga@gmail.com> | +1.201.308.3242 | Web
Presence <http://goo.gl/lW0nh>  *
Do not follow where the path may lead. Go instead where there is no path
and leave a trail. - Harold R. McAlindon


On Fri, Feb 21, 2014 at 9:26 AM, Kofford, C. Todd <tkofford@ku.edu> wrote:

> We've been running struts 2 apps as standalone and portlet using the same
> code/war file for a long time. We do use the portlet plugin and include 2
> different struts.xml configurations using different namespaces. For example
> our struts.xml file includes each configuration using includes as follows:
>
> struts.xml
> <struts>
> ...
>     <!-- Include the various configurations -->
>     <include file="struts-standalone.xml"/>
>     <include file="struts-portlet.xml"/>
>
> struts-standalone.xml
> <struts>
> ...
>     <!-- Configuration for the standalone package. -->
>     <package name="default" extends="struts-default" namespace="/sa">
>
> struts-portlet.xml (this one includes a reference to the
> portletDefaultStack inteceptor)
> <struts>
> ...
>     <!-- Configuration for the portlet package. -->
>     <package name="portlet-default" extends="struts-portlet-default"
> namespace="/portlet">
>
> This all works fine and has a lot of advantages. The portlet plugin has
> never caused any issues with our standalone webapp either.
>
> If you need more information on how we do this, I'd be happy to share
> details.
>
> Todd Kofford
> Academic Services Development
> KU Information Technology
> tkofford@ku.edu
> (785) 864-0327
>
> ________________________________________
> From: Lukasz Lenart [lukaszlenart@apache.org]
> Sent: Friday, February 21, 2014 1:53 AM
> To: Struts Developers List
> Subject: Re: Struts2 Portlet with Servlets
>
> As I understand at the same time you want to have the same web app
> exposed as portlet and as as a normal Struts2 app? It isn't possible
> to do in one Struts 2 app as attaching The Struts Portlet Plugin
> enables portlet integration for the whole app and some internals are
> changed (eg. how urls are rendered). You can use the same action in
> portlet and non-portlet app but not at the same time - you must remove
> portlet plugin to use it in non-portlet environment.
>
> 2014-02-20 20:24 GMT+01:00 Gaurav Daga <togauravdaga@gmail.com>:
> > And I did follow the tutorial and that's how I got upto the speed with
> > Struts2.  Also I didn't mention earlier, <s:url..> treats my Servlet
> Action
> > class as Portlet Action class and generates URL specific to it.
> >
> > I appreciate your help on this Lukasz.
> >
> >
> > *Thanks & Regards/ **सादर**,*
> > *Gaurav Daga*
> > *togauravdaga@gmail.com <togauravdaga@gmail.com> | +1.201.308.3242 | Web
> > Presence <http://goo.gl/lW0nh>  *
> > Do not follow where the path may lead. Go instead where there is no path
> > and leave a trail. - Harold R. McAlindon
> >
> >
> > On Thu, Feb 20, 2014 at 11:20 AM, Gaurav Daga <togauravdaga@gmail.com
> >wrote:
> >
> >> I used Struts2 filter, and here is web.xml for the same :
> >>           <filter>
> >>  <filter-name>struts2</filter-name>
> >> <filter-class>
> >>
> >> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
> >>                 </filter-class>
> >>  </filter>
> >>
> >>  <filter-mapping>
> >> <filter-name>struts2</filter-name>
> >>  <url-pattern>/servlet/*</url-pattern>
> >> </filter-mapping>
> >>
> >>
> >> *Thanks & Regards/ **सादर**,*
> >> *Gaurav Daga*
> >> *togauravdaga@gmail.com <togauravdaga@gmail.com> | +1.201.308.3242
> >> <%2B1.201.308.3242> | Web Presence <http://goo.gl/lW0nh>  *
> >> Do not follow where the path may lead. Go instead where there is no path
> >> and leave a trail. - Harold R. McAlindon
> >>
> >>
> >> On Thu, Feb 20, 2014 at 10:38 AM, Lukasz Lenart <
> lukaszlenart@apache.org>wrote:
> >>
> >>> You didn't provide your web.xml, have you tried follow the tutorial?
> >>>
> >>>
> http://struts.apache.org/release/2.3.x/docs/struts-2-portlet-tutorial.html
> >>>
> >>>
> >>> 2014-02-20 19:31 GMT+01:00 Gaurav Daga <togauravdaga@gmail.com>:
> >>> > 1. CaseTaskPortlet is a portlets action class.
> >>> > 2. caseTasks is servlet based action class.
> >>> >
> >>> > Problem I am having is, if I use <s:url....> tag to generate
endpoint
> >>> for
> >>> > my Servlet based action class, it doesn't work.  And I tried
> accessing
> >>> it
> >>> > from browser by constructing a URL manually, it doesn't invoke my
> >>> action.
> >>> >
> >>> > Looking at the below configuration, if you can suggest me like what
> >>> should
> >>> > be my URL to hit the displaySomeMessage() method inside
> CaseTasksAction
> >>> > action class?
> >>> >
> >>> >
> >>> > Below here is struts xml, I am having:
> >>> >
> >>> >
> >>> > <?xml version="1.0" encoding="UTF-8" ?>
> >>> > <!DOCTYPE struts PUBLIC
> >>> > "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
> >>> > "http://struts.apache.org/dtds/struts-2.3.dtd">
> >>> > <struts>
> >>> > <constant name="struts.devMode" value="true" />
> >>> > <package name="amps-base-package" extends="struts-portlet-default">
> >>> > <interceptors>
> >>> > <interceptor name="EJBInjectionInterceptor"
> >>> >
> >>>
> class="gov.nv.dwss.amps.presentation.struts.interceptors.EJBInjectionInterceptor"
> >>> > />
> >>> > <interceptor-stack name="baseStack">
> >>> > <interceptor-ref name="defaultStack" />
> >>> > <interceptor-ref name="EJBInjectionInterceptor" />
> >>> > </interceptor-stack>
> >>> > </interceptors>
> >>> > <default-interceptor-ref name="baseStack" />
> >>> > </package>
> >>> >  <constant name="struts.custom.i18n.resources"
> >>> >
> >>>
> value="gov.nv.dwss.framework.resourebundle.DplyTxtResourceBundle,gov.nv.dwss.framework.resourebundle.ValidationMessageResourceBundle"
> >>> > />
> >>> >
> >>> > <package name="view" extends="amps-base-package"
> >>> > namespace="/CaseTaskPortlet/view">
> >>> > <action name="HomeCaseTaskAction.*" method="{1}"
> >>> >
> >>>
> class="gov.nv.dwss.amps.casetask.presentation.action.HomeCaseTaskAction">
> >>> > <result name="home">/jsp/casetask/home.jsp</result>
> >>> > <result name="search">/jsp/casetask/search.jsp</result>
> >>> > <result name="expeditedSNAP">/jsp/casetask/expeditedSNAP.jsp</result>
> >>> > <result name="applications">/jsp/casetask/applications.jsp</result>
> >>> > <result name="changes">/jsp/casetask/changes.jsp</result>
> >>> > <result name="RDRCERTHOME">/jsp/casetask/rdrcert.jsp</result>
> >>> > <result name="mytasks">/jsp/casetask/mytasks.jsp</result>
> >>> >  </action>
> >>> > </package>
> >>> >  <package name="caseTasks" namespace="/caseTasks"
> >>> extends="struts-default">
> >>> >  <action name="CaseTasksAction"
> >>> >
>  class="gov.nv.dwss.amps.casetask.presentation.action.CaseTasksAction">
> >>> > <result name="servletHome">/jsp/casetask/test.jsp</result>
> >>> > </action>
> >>> > </package>
> >>> > </struts>
> >>> >
> >>> >
> >>> > *Thanks & Regards/ **सादर**,*
> >>> > *Gaurav Daga*
> >>> > *togauravdaga@gmail.com <togauravdaga@gmail.com> | +1.201.308.3242
|
> >>> Web
> >>> > Presence <http://goo.gl/lW0nh>  *
> >>> > Do not follow where the path may lead. Go instead where there is no
> path
> >>> > and leave a trail. - Harold R. McAlindon
> >>> >
> >>> >
> >>> > On Wed, Feb 19, 2014 at 10:07 PM, Lukasz Lenart <
> >>> lukaszlenart@apache.org>wrote:
> >>> >
> >>> >> But in struts.xml you can define actions - no reference to servlets
> >>> >> neither portlets. Do you have any error message?
> >>> >>
> >>> >> 2014-02-20 2:41 GMT+01:00 Gaurav Daga <togauravdaga@gmail.com>:
> >>> >> > Hello Struts2 Group,
> >>> >> >
> >>> >> > I have a requirement where I want to have Servlet Action
> Endpoint, as
> >>> >> well
> >>> >> > as Portlet Actions in the same WAR file. I tried configuring
the
> >>> >> > struts.xml, for the both package but Struts continued to give
me
> >>> error
> >>> >> > while resolving Servlet Action Endpoint.
> >>> >> >
> >>> >> > I just wanted to know if anyone has tries anything similar
to this
> >>> before
> >>> >> > and whether it is supported or not.  If you can throw me some
> >>> pointers,
> >>> >> > would be great help!
> >>> >> >
> >>> >> >
> >>> >> > Thanks.
> >>> >> > Gaurav Daga
> >>> >>
> >>> >>
> ---------------------------------------------------------------------
> >>> >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >>> >> For additional commands, e-mail: dev-help@struts.apache.org
> >>> >>
> >>> >>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >>> For additional commands, e-mail: dev-help@struts.apache.org
> >>>
> >>>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>
>
Mime
View raw message