It looks like you're confusing Tapestry by having both an ASO and a
persistent page property with the same name. Try changing your Login
class to be annotated like this instead:
@Persist("userProperty")
public abstract User getUser();
public abstract void setUser(User usr);
Or, if you really meant to be using the ASO and not a persistent page
property, use annotation @InjectState("user") instead of @Persist
("user").
--Chris
On Jan 27, 2006, at 8:06 AM, Cagan wrote:
Hello all,
I am quite new to Tapestry, trying to leave Struts behind...
I'm using Tapestry 4.0 running on Tomcat 5.5.15.
I'm trying to setup a system where there is a common base class for
all Pages that require a user to login first.
This is going to be a bit lenghty as I want to give all the details
of my setup...
For that, I wrote a simple AAdminPage :
@InjectStateFlag("user")
public abstract boolean getUserExists();
@InjectPage("Login")
public abstract Login getLoginPage();
/**
* @see
org.apache.tapestry.event.PageValidateListener#pageValidate
(org.apache.tapestry.event.PageEvent)
*/
public void pageValidate(PageEvent pe) {
if (!getUserExists()){
Login login = getLoginPage();
login.setNextPage(this);
throw new PageRedirectException(login);
}
}
and Login:
@InjectPage("Home")
public abstract Home getHomePage();
@Persist("user")
public abstract User getUser();
public abstract void setUser(User usr);
public IPage doSubmit(){
log.fine("-->doSubmit()");
try{
setUser(UserManager.authenticate(getEmail(), getPassword
()));
return getNextPage() == null ? getHomePage() :
getNextPage();
}catch(AuthenticationException ae){
return null;
}
}
public abstract void setEmail(String email);
public abstract void setPassword(String password);
public abstract String getEmail();
public abstract String getPassword();
public abstract void setNextPage(IPage page);
public abstract IPage getNextPage();
and Home is an empty class that simply extends AAdminPage..
I have in META-INF/hivemodule.xml:
<?xml version="1.0"?>
<module id="com.teknolabs.teknotrip" version="1.0.0">
<contribution configuration-
id="tapestry.state.ApplicationObjects">
<state-object name="user" scope="session">
<create-instance
class="com.teknolabs.teknotrip.model.company.User"/>
</state-object>
</contribution>
</module>
When I try to go to localhost:8080/app, I get the following error:
"'user' is not a declared application state object."
which is happening inside pageValidate method of AAdminPage at !
getUserExists() line...
t what is it that I'm doing wrong here?
Thanks in advance.
Cagan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]