PDA

View Full Version : Spring MVC with Tapestry [Solved]


GertThiel
08-16-2004, 08:04 AM
Hi.

Foreword: I´m a Java and Spring beginner. And my ten years of Delphi and mod_perl programming experience doesn´t help very much.

I want to use Jakarta Tapestry (http://jakarta.apache.org/tapestry/) for a Spring MVC view and still be able to use other techs for Spring MVC views as well. (I want to output PDFs using Spring´s AbstractPdfView (http://www.springframework.org/docs/reference/view.html#view-document-configsubclasspdf)).

I found the Tapestry-related chapter in the Spring reference (http://www.springframework.org/docs/reference/view.html#view-tapestry). But the presented integration strategy seem to force a exlusive Tapestry use.

Is there an alternative integration strategy?
Does someone have some code samples how to use Spring MVC with both Tapestry and AbstractPdfView?
Or any other hints?

Thanks in advance.

Colin Sampaleanu
08-16-2004, 08:55 AM
Gert,

There's nothing very exclusive about the Tapestry integration approach mentioned in the manual. I used that approach in an app to gradually move it over from being Struts-based to Tapestry based, and the app still has both Struts and Tapestry ui...

What makes you think you can't mix and match? It's just a matter of partitioning your incoming request paths.

Regards,

habuma
08-16-2004, 09:09 AM
I find the MyEngine implementation in the reference guide to be very generic and therefore reusable across multiple applications. Is there any chance that this class (with a name and package change, of course) could be rolled into Spring proper as a"standard" approach to Tapestry integration?

Colin Sampaleanu
08-16-2004, 09:12 AM
It's a possibility. The only problem is that the integration point is so small at this point that it seems a shame to actually bring in a dependency on Tapestry into the framework just for that...

Regards,

GertThiel
08-16-2004, 09:26 AM
Colin,

What makes you think you can't mix and match?
I have one servlet declared in my web.xml based on the org.apache.tapestry.ApplicationServlet class.

When I try some "partitioning" like this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<display-name>FlexLayout</display-name>

<filter>
<filter-name>redirect</filter-name>
<filter-class>org.apache.tapestry.RedirectFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>redirect</filter-name>
<url-pattern>/</url-pattern>
</filter-mapping>

<servlet>
<servlet-name>flexlayout</servlet-name>
<servlet-class>org.apache.tapestry.ApplicationServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>flexlayout</servlet-name>
<url-pattern>/app</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>flpdfpreview</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>flpdfpreview</servlet-name>
<url-pattern>/flpdfpreview</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

</web-app>

the code can be valided any more. So I think I can have more than one servlet in one web app.

It's just a matter of partitioning your incoming request paths.
Could you explain that in detail? Give an example, please? I learn most from samples, but have not found one sophisticated Spring MVC with Tapestry source example.

I support habuma´s request for a standard approach to Tapestry integration in the Spring framework like we have for FreeMarker and Velocity.

Regards

Colin Sampaleanu
08-16-2004, 09:44 AM
Gert,

What do you mean by, "the code can be validated anymore"? It's perfectly valid to have multiple servlets defined in your web.xml file. One can be for Tapestry, and then multiple other servlets can be for Spring-MVC, Struts, whatver.

FreeMarker and Velocity (and JSP) integration in Spring are fundamentally different than Tapestry integration. For the former, SpringMVC provides the controller logic, while FreeMarker/Velocity/JSP are just the view technology. When you talk about integrating Tapestry into Spring, it's about Tapestry being the entire view layer (no SpringMVC at all), or Tapestry running in parallel to SpringMVC. The connection between the two web ui frameworks in the latter case is simply via hyperlinks and the like between them. You can't use Tapestry as the view technology for SpringMVC, or use JSP as the view technology for Tapestry. That said, it's still a useful and valid approach to have both, and they can share the same application context definitions.

Regards,

GertThiel
08-16-2004, 10:05 AM
Colin,

What do you mean by, "the code can be validated anymore"?
Should have read "the code can´t be validated anymore".

In Eclipse 3 the XMLBuddy plugin give error messages like

The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".
web.xml FlexLayout/context/WEB-INF line 42


FreeMarker and Velocity (and JSP) integration in Spring are fundamentally different than Tapestry integration. For the former, SpringMVC provides the controller logic, while FreeMarker/Velocity/JSP are just the view technology. When you talk about integrating Tapestry into Spring, it's about Tapestry being the entire view layer (no SpringMVC at all), or Tapestry running in parallel to SpringMVC. The connection between the two web ui frameworks in the latter case is simply via hyperlinks and the like between them. You can't use Tapestry as the view technology for SpringMVC, or use JSP as the view technology for Tapestry. That said, it's still a useful and valid approach to have both, and they can share the same application context definitions.

That helped me to understand the fundamental difference between SpringMVC + FreeMarker/JSP/Velocity and Spring + Tapestry. Sould be made more clear in the docs.

May I habe a look at a sample web.xml?

Regards.

Colin Sampaleanu
08-16-2004, 10:09 AM
Gert,

You just need to keep your sevlet and servlet-mapping declarations (along with all the other elements) in the right order, as listed in the DTD. The parser is simply complaining about that. Just take a look at the DTD, it should be very simple to order things properly (in fact the order is given in the error message too).

Aside from that, your web.xm file is fine...

Regards,

GertThiel
08-16-2004, 10:10 AM
In Eclipse 3 the XMLBuddy plugin give error messages like

The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".
web.xml FlexLayout/context/WEB-INF line 42



Forget the validation stuff. I reordered the web.xml content and that helped. My fault :?

Regards.

{I submitted this post in parallel with Colin´s post. Multitasking and sync mismatch :wink:}.

GertThiel
08-17-2004, 04:46 AM
Colin,

It's just a matter of partitioning your incoming request paths.

I think, I´m still in trouble with that partitioning stuff. I created a new topic (Need help with SpringMVC and PDF (http://forum.springframework.org/showthread.php?t=9664)) regarding that.

You´re my brightest hope for help :).

Regards.

GertThiel
08-19-2004, 05:09 AM
http://forum.springframework.org/showthread.php?t=9664. Thanks and regards.