You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Chris Pratt <th...@gmail.com> on 2007/06/29 21:09:32 UTC
Tiles 2 and MyFaces example
Are their any examples around that show how to integrate Tiles 2 and
MyFaces? Even the web.xml and some pointers from someone who's done it
before would be a great help.
(*Chris*)
Re: Tiles 2 and MyFaces example
Posted by Antonio Petrelli <an...@gmail.com>.
Ray, how about adding this in the wiki?
http://cwiki.apache.org/confluence/display/TILES
Antonio
Re: Tiles 2 and MyFaces example
Posted by Antonio Petrelli <an...@gmail.com>.
2007/10/29, Navid Mitchell <na...@m2r2.com>:
>
>
> Here is the http://www.nabble.com/file/p13463377/TilesViewHandler.java
> TilesViewHandler.java I used with the struts2-jsf-plugin and Tiles 2.
Doh! another view handler!
Navid, why don't you post it to the MyFaces (Tomahawk) JIRA?
https://issues.apache.org/jira/browse/TOMAHAWK/component/12310781
Antonio
Re: Tiles 2 and MyFaces example
Posted by Navid Mitchell <na...@m2r2.com>.
Here is the http://www.nabble.com/file/p13463377/TilesViewHandler.java
TilesViewHandler.java I used with the struts2-jsf-plugin and Tiles 2.
You will also need to follow the guidelines for configuring Tiles 2 within
your Web XML.
Also you will need to specify the proper ViewHandler within the
FacesSetupInterceptor details can be found here.
http://struts.apache.org/2.x/struts2-plugins/struts2-jsf-plugin/apidocs/index.html
--
View this message in context: http://www.nabble.com/Tiles-2-and-MyFaces-example-tf4001471.html#a13463377
Sent from the tiles users mailing list archive at Nabble.com.
Re: Tiles 2 and MyFaces example
Posted by Chris Pratt <th...@gmail.com>.
Ray, I've been fighting with this for a while and it's just proving how
little I know about the inner working of Tile (past and present). Any
chance you could share your updated version?
(*Chris*)
On 6/29/07, Ray Clough <rc...@kamakuraco.com> wrote:
>
> The Shale site has a file "ShaleTiles" which does not require Shale to
> run, in fact it is JSF implementation neutral. That is how we do Tiles
> with MyFaces. Unfortunately the version available on the Shale site
> uses a really old version of Tiles2. What we had to do was get the
> source code for the ShaleTiles project and modify it to use the new
> paths/methods/etc for the later Tiles version. I'm sure there are other
> solutions, but that was pretty easy, just took a 1 or 2 hours of time to
> do. We were not particularly expert in the Tiles code base, but there
> is really only one Java file with 2 methods.
>
> Ray Clough
> Software Development
> The Kamakura Corporation
> 2222 Kalakaua Avenue 14th Floor, Honolulu, HI 96815
> Phone: 1.808.791.9888 x 8532 Fax: 1.808.791.9898
> Email: rcclough@kamakuraco.com Web: www.kamakuraco.com
>
>
>
> Chris Pratt wrote:
> > You may not have run into this because you are using Struts 1 (I'm
> > attempting to use straight MyFaces with Tiles 2), but when the web app
> > starts up, I get the an exception, is there any way to prevent this?
> > (*Chris*)
> >
> > java.lang.NoClassDefFoundError:
> > org/apache/struts/tiles/DefinitionsFactoryException
> > at java.lang.Class.getDeclaredConstructors0(Native Method)
> > at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
> > at java.lang.Class.getConstructor0(Class.java:2671)
> > at java.lang.Class.getConstructor(Class.java:1629)
> > at org.apache.myfaces.config.FacesConfigurator.getApplicationObject(
> > FacesConfigurator.java:677)
> > at org.apache.myfaces.config.FacesConfigurator.configureApplication(
> > FacesConfigurator.java:602)
> > at org.apache.myfaces.config.FacesConfigurator.configure(
> > FacesConfigurator.java:148)
> > at org.apache.myfaces.webapp.StartupServletContextListener.initFaces(
> > StartupServletContextListener.java:68)
> > at
> >
> org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized
> (
> >
> > StartupServletContextListener.java:51)
> > at com.caucho.server.webapp.Application.start(Application.java:1647)
> > at com.caucho.server.deploy.DeployController.startImpl(
> > DeployController.java:621)
> > at com.caucho.server.deploy.DeployController.restartImpl(
> > DeployController.java:584)
> > at com.caucho.server.deploy.StartAutoRedeployAutoStrategy.alarm(
> > StartAutoRedeployAutoStrategy.java:176)
> > at com.caucho.server.deploy.DeployController.handleAlarm(
> > DeployController.java:742)
> > at com.caucho.util.Alarm.handleAlarm(Alarm.java:339)
> > at com.caucho.util.Alarm.run(Alarm.java:309)
> > at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:516)
> > at com.caucho.util.ThreadPool.run(ThreadPool.java:442)
> > at java.lang.Thread.run(Thread.java:595)
> >
> >
> > On 6/29/07, Greg Reddin <gr...@gmail.com> wrote:
> >>
> >> On 6/29/07, Ray Clough <rc...@kamakuraco.com> wrote:
> >> >
> >> > I have an app using S2, S1, MyFaces, and Tiles. We are using
> >> > Tiles-2.0.4 in all three modules, so we are not using the
> Struts-Tiles
> >> > plugins either in S1 or S2. All pages are Tiles, even the JSF pages.
> >>
> >>
> >>
> >> Wow! That's impressive!. Thanks for sharing.
> >>
> >
>
Re: Tiles 2 and MyFaces example
Posted by Ray Clough <rc...@kamakuraco.com>.
The Shale site has a file "ShaleTiles" which does not require Shale to
run, in fact it is JSF implementation neutral. That is how we do Tiles
with MyFaces. Unfortunately the version available on the Shale site
uses a really old version of Tiles2. What we had to do was get the
source code for the ShaleTiles project and modify it to use the new
paths/methods/etc for the later Tiles version. I'm sure there are other
solutions, but that was pretty easy, just took a 1 or 2 hours of time to
do. We were not particularly expert in the Tiles code base, but there
is really only one Java file with 2 methods.
Ray Clough
Software Development
The Kamakura Corporation
2222 Kalakaua Avenue 14th Floor, Honolulu, HI 96815
Phone: 1.808.791.9888 x 8532 Fax: 1.808.791.9898
Email: rcclough@kamakuraco.com Web: www.kamakuraco.com
Chris Pratt wrote:
> You may not have run into this because you are using Struts 1 (I'm
> attempting to use straight MyFaces with Tiles 2), but when the web app
> starts up, I get the an exception, is there any way to prevent this?
> (*Chris*)
>
> java.lang.NoClassDefFoundError:
> org/apache/struts/tiles/DefinitionsFactoryException
> at java.lang.Class.getDeclaredConstructors0(Native Method)
> at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
> at java.lang.Class.getConstructor0(Class.java:2671)
> at java.lang.Class.getConstructor(Class.java:1629)
> at org.apache.myfaces.config.FacesConfigurator.getApplicationObject(
> FacesConfigurator.java:677)
> at org.apache.myfaces.config.FacesConfigurator.configureApplication(
> FacesConfigurator.java:602)
> at org.apache.myfaces.config.FacesConfigurator.configure(
> FacesConfigurator.java:148)
> at org.apache.myfaces.webapp.StartupServletContextListener.initFaces(
> StartupServletContextListener.java:68)
> at
> org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(
>
> StartupServletContextListener.java:51)
> at com.caucho.server.webapp.Application.start(Application.java:1647)
> at com.caucho.server.deploy.DeployController.startImpl(
> DeployController.java:621)
> at com.caucho.server.deploy.DeployController.restartImpl(
> DeployController.java:584)
> at com.caucho.server.deploy.StartAutoRedeployAutoStrategy.alarm(
> StartAutoRedeployAutoStrategy.java:176)
> at com.caucho.server.deploy.DeployController.handleAlarm(
> DeployController.java:742)
> at com.caucho.util.Alarm.handleAlarm(Alarm.java:339)
> at com.caucho.util.Alarm.run(Alarm.java:309)
> at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:516)
> at com.caucho.util.ThreadPool.run(ThreadPool.java:442)
> at java.lang.Thread.run(Thread.java:595)
>
>
> On 6/29/07, Greg Reddin <gr...@gmail.com> wrote:
>>
>> On 6/29/07, Ray Clough <rc...@kamakuraco.com> wrote:
>> >
>> > I have an app using S2, S1, MyFaces, and Tiles. We are using
>> > Tiles-2.0.4 in all three modules, so we are not using the Struts-Tiles
>> > plugins either in S1 or S2. All pages are Tiles, even the JSF pages.
>>
>>
>>
>> Wow! That's impressive!. Thanks for sharing.
>>
>
Re: Tiles 2 and MyFaces example
Posted by Chris Pratt <th...@gmail.com>.
You may not have run into this because you are using Struts 1 (I'm
attempting to use straight MyFaces with Tiles 2), but when the web app
starts up, I get the an exception, is there any way to prevent this?
(*Chris*)
java.lang.NoClassDefFoundError:
org/apache/struts/tiles/DefinitionsFactoryException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
at java.lang.Class.getConstructor0(Class.java:2671)
at java.lang.Class.getConstructor(Class.java:1629)
at org.apache.myfaces.config.FacesConfigurator.getApplicationObject(
FacesConfigurator.java:677)
at org.apache.myfaces.config.FacesConfigurator.configureApplication(
FacesConfigurator.java:602)
at org.apache.myfaces.config.FacesConfigurator.configure(
FacesConfigurator.java:148)
at org.apache.myfaces.webapp.StartupServletContextListener.initFaces(
StartupServletContextListener.java:68)
at
org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(
StartupServletContextListener.java:51)
at com.caucho.server.webapp.Application.start(Application.java:1647)
at com.caucho.server.deploy.DeployController.startImpl(
DeployController.java:621)
at com.caucho.server.deploy.DeployController.restartImpl(
DeployController.java:584)
at com.caucho.server.deploy.StartAutoRedeployAutoStrategy.alarm(
StartAutoRedeployAutoStrategy.java:176)
at com.caucho.server.deploy.DeployController.handleAlarm(
DeployController.java:742)
at com.caucho.util.Alarm.handleAlarm(Alarm.java:339)
at com.caucho.util.Alarm.run(Alarm.java:309)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:516)
at com.caucho.util.ThreadPool.run(ThreadPool.java:442)
at java.lang.Thread.run(Thread.java:595)
On 6/29/07, Greg Reddin <gr...@gmail.com> wrote:
>
> On 6/29/07, Ray Clough <rc...@kamakuraco.com> wrote:
> >
> > I have an app using S2, S1, MyFaces, and Tiles. We are using
> > Tiles-2.0.4 in all three modules, so we are not using the Struts-Tiles
> > plugins either in S1 or S2. All pages are Tiles, even the JSF pages.
>
>
>
> Wow! That's impressive!. Thanks for sharing.
>
Re: Tiles 2 and MyFaces example
Posted by Greg Reddin <gr...@gmail.com>.
On 6/29/07, Ray Clough <rc...@kamakuraco.com> wrote:
>
> I have an app using S2, S1, MyFaces, and Tiles. We are using
> Tiles-2.0.4 in all three modules, so we are not using the Struts-Tiles
> plugins either in S1 or S2. All pages are Tiles, even the JSF pages.
Wow! That's impressive!. Thanks for sharing.
Re: Tiles 2 and MyFaces example
Posted by Ray Clough <rc...@kamakuraco.com>.
I have an app using S2, S1, MyFaces, and Tiles. We are using
Tiles-2.0.4 in all three modules, so we are not using the Struts-Tiles
plugins either in S1 or S2. All pages are Tiles, even the JSF pages.
Normally, to use Tiles in S2, you specify the 'type' parameter on the
result mappings. However that interferes with dispatching the result to
JSF. So getting rid of the Struts-tiles plugins, and having the S2
requests forward to "/SomeTile.tiles" works fine. In fact, based on our
success with that, I can't see why anyone would want to use the Plugin.
Integrating all these frameworks was a lot of work. The most
difficult part was getting I18N messages to work not only in the S1, S2,
and JSF pages, but also in back-end modules, which do not have any
Struts components or access to the Session. Here is a portion of our
web.xml file (pretty big file, sorry):
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<!-- ....... -->
<!-- <context-param>
<param-name>org.apache.tiles.CONTEXT_FACTORY</param-name>
<param-value>
org.apache.tiles.context.enhanced.EnhancedContextFactory
</param-value>
</context-param>-->
<!-- Define Tiles config files -->
<context-param>
<param-name>
org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG
</param-name>
<param-value>
/WEB-INF/config/tiles_rp.xml,
/WEB-INF/config/tiles_dm.xml,
/WEB-INF/config/tiles_pm.xml,
/WEB-INF/config/tiles_as.xml
</param-value>
</context-param>
<!-- use javascript to restore vertical scroll on every request -->
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>false</param-value>
</context-param>
<!-- faces-config.xlm is in standard place (as defined in tomahawk jar)
- don't want to duplicate
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param> -->
<!-- Filter to redirect requests generated by Struts-1 to the
Struts-2 'Welcome.action', if there is no User login credential
in the Session. -->
<filter>
<description>
Since the user may bookmark a Struts-1 page, the submitted
request would not be fully processed by the Struts-2 filter,
which means that the LoginInterceptor would not be executed,
with a resultant gaping security hole. This Filter will
redirect any request without a User login credential in their
Session. This filter will be mapped to '*.do' to catch
requests
generated by Struts-1 and to '*.jsf' to catch requests generated
from JSF pages.
</description>
<filter-name>LoginRedirectFilter</filter-name>
<filter-class>
com.kamakura.struts2.interceptor.LoginRedirectFilter
</filter-class>
<init-param>
<param-name>redirectURL</param-name>
<param-value>/reports/Welcome.action</param-value>
</init-param>
</filter>
<filter>
<description>
This filter executes code to initialize the user, where the
Request state is "LoggedIn = true" and "Initialized = false".
The discriminator for "LoggedIn" is the presence in the session
of a "DBUser" object. The discriminator for "Initialized" is
the presence in the session of a Locale object.
The initialization process consists of retrieving the Locale
preferences from the ( database / cookies / request ) and
storing
it in the session.
</description>
<filter-name> UserInitializerFilter </filter-name>
<filter-class>
com.kamakura.struts2.interceptor.UserInitializerFilter
</filter-class>
</filter>
<!-- Filter (Struts-2) -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter>
<display-name>Ajax4jsf Filter</display-name>
<filter-name>ajax4jsf</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<!-- The MyFacesExtensionsFilter is used by some of the more
sophisticated
'Tomahawk' components to provide resources. -->
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>
org.apache.myfaces.webapp.filter.ExtensionsFilter
</filter-class>
<init-param>
<param-name>maxFileSize</param-name>
<param-value>20m</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>LoginRedirectFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>LoginRedirectFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>UserInitializerFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>UserInitializerFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>UserInitializerFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<!-- Struts-2 filter mapping -->
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ajax4jsf</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>
<!-- Listener (Struts-2) -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- Listener for Tiles-2 -->
<listener>
<listener-class>
org.apache.tiles.web.startup.TilesListener
</listener-class>
</listener>
<!-- Listener for 'MyFaces' jsf components. -->
<listener>
<listener-class>
org.apache.myfaces.webapp.StartupServletContextListener
</listener-class>
</listener>
<!-- Struts-1 Servlet -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<!-- <init-param>
<param-name>chainConfig</param-name>
<param-value>org/apache/struts/tiles/chain-config.xml</param-value>
</init-param>
-->
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/config/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<!-- Tiles-2 Dispatch Servlet -->
<servlet>
<servlet-name>Tiles Dispatch Servlet</servlet-name>
<servlet-class>
org.apache.tiles.web.util.TilesDispatchServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Tiles Dispatch Servlet</servlet-name>
<url-pattern>*.tiles</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<!-- The Welcome File List (forwards to Struts-2 'Welcome.action') -->
<welcome-file-list>
<welcome-file>html/index.html</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
Ray Clough
Software Development
The Kamakura Corporation
2222 Kalakaua Avenue 14th Floor, Honolulu, HI 96815
Phone: 1.808.791.9888 x 8532 Fax: 1.808.791.9898
Email: rcclough@kamakuraco.com Web: www.kamakuraco.com
Chris Pratt wrote:
> Are their any examples around that show how to integrate Tiles 2 and
> MyFaces? Even the web.xml and some pointers from someone who's done it
> before would be a great help.
> (*Chris*)
>