aspose file tools*
The moose likes Struts and the fly likes integrating tapestry and Spring (long) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "integrating tapestry and Spring (long)" Watch "integrating tapestry and Spring (long)" New topic
Author

integrating tapestry and Spring (long)

Dave Wellington
Greenhorn

Joined: Jun 14, 2004
Posts: 4
I am starting a project using Spring, Tapestry and Hibernate. I cannot get off the ground with the Spring/Tapestry part, as I am getting the following exception thrown from Tapestry.

org.apache.tapestry.ApplicationRuntimeException
Unable to update expression '<parsed expression>' of com.crosswind.mha.tapestry.pages.Home$Enhance_0@d5c653[Home] to com.crosswind.mha.services.AuthenticationService@161def0.

ognl.MethodFailedException
Method "setAuthenticationService" failed for object com.crosswind.mha.tapestry.pages.Home$Enhance_0@d5c653[Home]

java.lang.NoSuchMethodException
setAuthenticationService($Proxy9)

Any help would be appreciated. Hopefully I am doing something dumb.

Here is a simplified Home.java, Home.page and Home.html (using Howard's simple login example), all of which seem to do the right thing, per the "Integrating Tapestry and the Spring framework" paper by Colin Sampaleanu.

Home.java
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package com.crosswind.mha.tapestry.pages;

import com.crosswind.mha.entities.people.Person;
import com.crosswind.mha.services.AuthenticationService;
import com.crosswind.mha.services.AuthenticationServiceException;

import com.crosswind.mha.tapestry.util.Visit;

import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.html.BasePage;


/**
* Demonstration of very simple form support.
*
* @author Howard Lewis Ship
*/
public abstract class Home extends BasePage
{
// Abstract accessors provided by Tapestry in enhanced
// subclass. We only declare the accessors we need in code,
// but the properties are always read/write.

public abstract String getUserName();
public abstract String getPassword();
public abstract void setMessage(String message);

// our UserService implementation; will come from page definition
// public abstract UserService getUserService();

// our AuthenticationService implementation; will come from page definition
public abstract AuthenticationService getAuthenticationService();

private String errorMessage;

public void login(IRequestCycle cycle)
{
Person person;

person = validateLogin(getUserName(), getPassword());

if (person != null) {
Visit visit = (Visit) getVisit();
java.lang.String newPage = visit.getStartPage(person);
cycle.activate(newPage);
return;
}
setMessage(errorMessage);
}

private Person validateLogin(String userName, String password)
{
Person person = null;

try {
person = getAuthenticationService().authenticate(userName, password);
} catch (AuthenticationServiceException e) {
errorMessage = e.getMessage();
return null;
}
if (person == null) {
errorMessage = "Invalid user name or password.";
}
return person;
}
}

Home.html:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<html jwcid="@Shell" title="Login">
<body>

<span jwcid="@Conditional" condition="ognl:message">
<font color="red">
<span jwcid="@Insert" value="ognl:message">
Error Message
</span>
</font>
</span>

<p/>

<form jwcid="@Form" listener="ognl:listeners.login">

<table>
<tr>
<th>User Name:</th>
<td>
<input type="text" jwcid="@TextField"
value="ognl:userName"
size="30"/></td>
</tr>
<tr>
<th>Password:</th>
<td>
<input type="password" jwcid="@TextField"
value="ognl assword"
hidden="ognl:true"
size="30"/>
</td>
</tr>
<tr>
<td><input type="submit" value="Login"/></td>
</tr>
</table>

</form>


<hr/>
<p><a href="#" jwcid="@PageLink" page="Home">Return to Home page</a>.</p>
</body>
</html>


Home.page
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<?xml version="1.0"?>
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">

<page-specification class="com.crosswind.mha.tapestry.pages.Home">

<property-specification name="message" type="java.lang.String"/>
<property-specification name="userName" type="java.lang.String"/>
<property-specification name="password" type="java.lang.String"/>

<property-specification name="authenticationService"
type="com.crosswind.mha.services.AuthenticationService">
global.appContext.getBean("authenticationService")
</property-specification>

</page-specification>
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
"Walt Whitman",

Welcome to JavaRanch. We don't have many rules here, but we do have a naming policy. One of the things that policy states is that obviously ficticious names are not allowed. Please edit your display name to comply with this policy. Thanks in advance, and we look forward to seeing you around the Ranch.
Dave Wellington
Greenhorn

Joined: Jun 14, 2004
Posts: 4
Done.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: integrating tapestry and Spring (long)