Hi all!
Was there a solution to this really strange ClassCastException already?
I have the same problem in the following circumstances:
public class Search extends BaseComponent
{
@Component
private Form simpleSearch;
@ApplicationState
private SimpleSearchString simpleSearchString;
private String searchTerm; // wil be populated by the form;
/* Form Handler */
String onSuccess()
{
if (searchTerm == null)
return null;
getSimpleSearchString().setSearchTerm(searchTerm);
return "ExtendedSearch";
}
public SimpleSearchString getSimpleSearchString()
{
return simpleSearchString;
}
This line gives the following stacktrace
java.lang.ClassCastException myapp.state.SimpleSearchString cannot be cast
to myapp.state.SimpleSearchString
Stack trace
- myapp.components.search.Search._$read_simpleSearchString(Search.java
)
- myapp.components.search.Search.getSimpleSearchString(Search.java:79)
- myapp.components.search.Search.onSuccess(Search.java:53)
- myapp.components.search.Search.handleComponentEvent(Search.java)
This happens regardless of if I access simpleSearchString directly or with
the getter.
Any idead what causes this somewhat puzzling behaviour?
Regards,
Otho
2007/5/11, Juan Maya <[EMAIL PROTECTED]>:
> i think u can only access ur ASOs in pages or components. I am not sure
> about it :S
>
> On 5/11/07, Eric Chatellier <[EMAIL PROTECTED]> wrote:
> >
> > thanks, it' works
> >
> > I check if user is authenticated and if not redirect to loginForm
> >
> > but now I got a strange error using @ApplicationState
> >
> > @ApplicationState
> > private SessionBean sessionBean;
> >
> > In this form, when I try to log the user sessionBean.setLogged(true),
> > this excepion is thrown :
> >
> > org.package.test.web.tapestry.base.SessionBean cannot be cast to
> > org.package.test.web.tapestry.base.SessionBean
> >
> > The cast done by tapestry seams good, so how this exception can be
throw ?
> >
> >
> > 2007/5/11, Juan Maya <[EMAIL PROTECTED]>:
> > > Hi Eric,
> > > i think the best way to do it is to contrib to the Request handler
> > pipilene
> > > (
http://tapestry.apache.org/tapestry5/tapestry-core/guide/request.html)
> > > To contrib to a pipeline do it your AppModule:
> > >
> > > public RequestFilter buildTimingFilter(final Log log) {
> > > return new RequestFilter() {
> > > public boolean service(Request request, Response response,
> > > RequestHandler handler) throws IOException {
> > > long startTime = System.currentTimeMillis();
> > > try {
> > > // The reponsibility of a filter is to invoke the
> > > // corresponding method
> > > // in the handler. When you chain multiple filters
> > > // together, each filter
> > > // received a handler that is a bridge to the next
> > > // filter.
> > > return handler.service(request, response);
> > >
> > > } finally {
> > > long elapsed = System.currentTimeMillis() - startTime;
> > > log.info(String.format("Request time: %d ms",
Long.valueOf
> > > (elapsed)));
> > > }
> > > }
> > > };
> > > }
> > >
> > >
> > > /**
> > > * This is a contribution to the RequestHandler service
> > configuration.
> > > * This is how we extend Tapestry using the timing filter. A
common
> > use
> > > * for this kind of filter is transaction management or
security.
> > > */
> > > public void
> > contributeRequestHandler(OrderedConfiguration<RequestFilter>
> > > configuration, @InjectService("TimingFilter") RequestFilter filter)
{
> > > // Each contribution to an ordered configuration has a name,
When
> > > // necessary, you may
> > > // set constraints to precisely control the invocation order of
the
> > > // contributed filter
> > > // within the pipeline.
> > > configuration.add("Timing", filter);
> > > }
> > >
> > >
> > >
> > > On 5/11/07, Eric Chatellier <[EMAIL PROTECTED]> wrote:
> > > >
> > > > hi everyone
> > > >
> > > > I'm starting using Tapestry 5.0.4 and i'm tying to implement an
> > > > authentication filter.
> > > >
> > > >
> > > > In some tapestry 4 samples, code was :
> > > >
> > > > public abstract class AuthenticatedPage implements
> > PageValidateListener {
> > > >
> > > > public void pageValidate(PageEvent event) {
> > > >
> > > > if (!isSessionBeanExist() ||
> > > > getSessionBean().getUid()==-1) {
> > > > Login loginPage = (Login)getRequestCycle()
> > > >
> > > > .getPage("Login");
> > > >
> > > > loginPage.setCallback(new
PageCallback(this));
> > > >
> > > > throw new
PageRedirectException(loginPage);
> > > > }
> > > > }
> > > > }
> > > >
> > > > public class ProjectList extends AuthenticatedPage {
> > > > [...]
> > > > }
> > > >
> > > > but i can't find the way to do it in tapestry 5.
> > > >
> > > > thanks in advance for help, and sorry for my bad english ;)
> > > >
> > > >
---------------------------------------------------------------------
> > > > 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]
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]