« Return to Thread: list + search

Re: list + search

by Alejandro Scandroli :: Rate this Message:

Reply to Author | View in Thread

Hi Pablo

I see your issue now.
First of all I didn't expect it to work at all, so I'm quite surprised.
The "criteria" is created on the SearchForm.pageBeginRender method, so
it's not being shared across requests.
The search field values aren't persisted in either client or session.
They neither are binded to anything so I would asume they should be
NULL every time we take the component out of the editors page.
It looks like my asumtions were wrong, the values ARE shared across
all the instances of the same component in the same request cycle.

I think this fixes it:

+++ modules/trails-hibernate/src/main/java/org/trails/component/search/SimpleSearchField.java Thu
Jul 03 12:28:55 CEST 2008
+ protected void cleanupAfterRender(IRequestCycle cycle)
+ {
+ setValue(null);
+ }

But I have to do a deeper test to confirm.
Please test the attached patch and then let me know how it goes.


Saludos.
Alejandro.

--
Alejandro Scandroli - http://weblog.amneris.es/
Amneris: We build process-driven web applications.
http://www.amneris.es



On Thu, Jul 3, 2008 at 4:00 AM, Pablo Gra~na <pablo.grana@...> wrote:

> no, just what I posted. Just to be sure, I deleted my local maven
> repository, checked out the head from scratch, applied the patch and
> rebuilt. It gave the same result I posted earlier: the search form gets
> populated with the wrong values.
>
> thank a lot.
>
> Ken in nashua wrote:
>>
>> did you make modifications to the *.page file?
>> If so what are they.
>>
>> Best regards
>> Ken in nashua
>>
>>
>>
>> ------------------------------------------------------------------------
>> From: nhhockeyplayer@...
>> To: users@...
>> Date: Wed, 2 Jul 2008 12:02:27 -0400
>> Subject: RE: [trails-users] list + search
>>
>> My runtime produces this...
>>
>> I am working on getting it running
>>
>> An exception has occurred. You may continue by *restarting
>> <http://localhost:8080/restart.svc>* the session.
>> [ +/- ] Exception: java.lang.NullPointerException
>> <http://localhost:8080/trails/list/League#>
>> org.apache.hivemind.ApplicationRuntimeException
>>
>> component:
>>
>>        $HibernateListPage_15@3c1[LeagueList]
>>
>> location:
>>
>>        context:/WEB-INF/DefaultList.page, line 3, column 63
>> 1
>>
>>        <!DOCTYPE page-specification PUBLIC "-//Apache Software
>> Foundation//Tapestry Specification 4.1//EN"
>>
>> 2
>>
>>           "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_1.dtd">
>>
>> 3
>>
>>        <page-specification class="org.trails.page.HibernateListPage">
>>
>> 4
>>
>>
>>
>> 5
>>
>>          <property name="instances" persist="session"/>
>>
>> 6
>>
>>          <property name="criteria" persist="session"/>
>>
>> 7
>>
>>          <property name="classDescriptor" persist="session"/>
>>
>> 8
>>
>>
>>
>>
>>
>>
>> [ +/- ] Exception: java.lang.NullPointerException
>> <http://localhost:8080/trails/list/League#>
>> org.trails.exception.TrailsRuntimeException
>> Stack Trace:
>>
>>    *
>> org.trails.component.AbstractPropertySelectionModel.getLabel(AbstractPropertySelectionModel.java:92)
>>
>>    *
>> org.apache.tapestry.form.DefaultOptionRenderer.renderOptions(DefaultOptionRenderer.java:60)
>>
>>    *
>> org.apache.tapestry.form.PropertySelection.renderFormComponent(PropertySelection.java:75)
>>
>>    *
>> org.apache.tapestry.form.AbstractFormComponent.renderComponent(AbstractFormComponent.java:104)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:724)
>>
>>    *
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:187)
>>
>>    *
>> org.apache.tapestry.BaseComponent.renderComponent(BaseComponent.java:107)
>>
>>    *
>> org.trails.component.search.SimpleSearchField.renderComponent(SimpleSearchField.java:44)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:724)
>>
>>    *
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:187)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:538)
>>
>>    *
>> org.apache.tapestry.components.Block.renderForComponent(Block.java:65)
>>
>>    *
>> org.apache.tapestry.components.RenderBlock.renderComponent(RenderBlock.java:65)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:724)
>>
>>    *
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:187)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:538)
>>
>>    *
>> org.apache.tapestry.components.ForBean.renderComponent(ForBean.java:181)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:724)
>>
>>    *
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:187)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:538)
>>
>>    *
>> org.apache.tapestry.form.FormSupportImpl.render(FormSupportImpl.java:503)
>>
>>    * org.apache.tapestry.form.Form.renderComponent(Form.java:217)
>>    *
>> org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:724)
>>
>>    *
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:187)
>>
>>    *
>> org.apache.tapestry.BaseComponent.renderComponent(BaseComponent.java:107)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:724)
>>
>>    *
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:187)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:538)
>>
>>    *
>> org.apache.tapestry.components.RenderBody.renderComponent(RenderBody.java:39)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:724)
>>
>>    *
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:187)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:538)
>>
>>    * org.apache.tapestry.html.Body.renderComponent(Body.java:38)
>>    *
>> org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:724)
>>
>>    *
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:187)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:538)
>>
>>    * org.apache.tapestry.html.Shell.renderComponent(Shell.java:125)
>>    *
>> org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:724)
>>
>>    *
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:187)
>>
>>    *
>> org.apache.tapestry.BaseComponent.renderComponent(BaseComponent.java:107)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:724)
>>
>>    *
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:187)
>>
>>    *
>> org.apache.tapestry.BaseComponent.renderComponent(BaseComponent.java:107)
>>
>>    *
>> org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:724)
>>
>>    *
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:185)
>>
>>    * org.apache.tapestry.AbstractPage.renderPage(AbstractPage.java:249)
>>    *
>> org.apache.tapestry.engine.RequestCycle.renderPage(RequestCycle.java:400)
>>
>>    *
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.renderResponse(DefaultResponseBuilder.java:159)
>>
>>    *
>> org.apache.tapestry.services.impl.ResponseRendererImpl.renderResponse(ResponseRendererImpl.java:33)
>>
>>    *
>> $ResponseRenderer_11ae45b759a.renderResponse($ResponseRenderer_11ae45b759a.java)
>>
>>    *
>> org.trails.engine.TrailsPagesService.service(TrailsPagesService.java:111)
>>
>>    * $IEngineService_11ae45b760b.service($IEngineService_11ae45b760b.java)
>>    *
>> org.apache.tapestry.services.impl.EngineServiceOuterProxy.service(EngineServiceOuterProxy.java:72)
>>
>>    *
>> org.apache.tapestry.engi`ne.AbstractEngine.service(AbstractEngine.java:241)
>>
>
>>    *
>> org.apache.tapestry.services.impl.InvokeEngineTerminator.service(InvokeEngineTerminator.java:54)
>>
>>    *
>> $WebRequestServicer_11ae45b75e4.service($WebRequestServicer_11ae45b75e4.java)
>>
>>    *
>> $WebRequestServicer_11ae45b75e0.service($WebRequestServicer_11ae45b75e0.java)
>>
>>    *
>> org.apache.tapestry.services.impl.WebRequestServicerPipelineBridge.service(WebRequestServicerPipelineBridge.java:61)
>>
>>    *
>> $ServletRequestServicer_11ae45b75c6.service($ServletRequestServicer_11ae45b75c6.java)
>>
>>    *
>> org.apache.tapestry.request.DecodedRequestInjector.service(DecodedRequestInjector.java:55)
>>
>>    *
>> $ServletRequestServicerFilter_11ae45b75c2.service($ServletRequestServicerFilter_11ae45b75c2.java)
>>
>>    *
>> $ServletRequestServicer_11ae45b75c8.service($ServletRequestServicer_11ae45b75c8.java)
>>
>>    *
>> org.apache.tapestry.multipart.MultipartDecoderFilter.service(MultipartDecoderFilter.java:52)
>>
>>    *
>> $ServletRequestServicerFilter_11ae45b75c0.service($ServletRequestServicerFilter_11ae45b75c0.java)
>>
>>    *
>> $ServletRequestServicer_11ae45b75c8.service($ServletRequestServicer_11ae45b75c8.java)
>>
>>    *
>> org.apache.tapestry.services.impl.SetupRequestEncoding.service(SetupRequestEncoding.java:53)
>>
>>    *
>> $ServletRequestServicerFilter_11ae45b75c4.service($ServletRequestServicerFilter_11ae45b75c4.java)
>>
>>    *
>> $ServletRequestServicer_11ae45b75c8.service($ServletRequestServicer_11ae45b75c8.java)
>>
>>    *
>> $ServletRequestServicer_11ae45b75ba.service($ServletRequestServicer_11ae45b75ba.java)
>>
>>    *
>> org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:126)
>>
>>    *
>> org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:103)
>>
>>    * javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>>    * javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>>    *
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491)
>>
>>    *
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1074)
>>
>>    *
>> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
>>
>>    *
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
>>
>>    *
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
>>
>>    *
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
>>
>>    *
>> org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
>>
>>    *
>> org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
>>
>>    *
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>>
>>    *
>> org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
>>
>>    *
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>>
>>    *
>> org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
>>
>>    *
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>>
>>    *
>> org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
>>
>>    *
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>>
>>    *
>> org.trails.security.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:152)
>>
>>    *
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>>
>>    *
>> org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:229)
>>
>>    *
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>>
>>    *
>> org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:286)
>>
>>    *
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>>
>>    *
>> org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
>>
>>    *
>> org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
>>
>>    *
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
>>
>>    *
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
>>
>>    *
>> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
>>
>>    *
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>
>>    *
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
>>
>>    * org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
>>    *
>> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
>>
>>    *
>> org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
>>
>>    *
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>>
>>    * org.mortbay.jetty.Server.handle(Server.java:285)
>>    *
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
>>
>>    *
>> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:751)
>>
>>    * org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:500)
>>    * org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209)
>>    * org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
>>    *
>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
>>
>>    *
>> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
>>
>>    * Caused by: java.lang.NullPointerException
>>    *
>> org.trails.component.AbstractPropertySelectionModel.getLabel(AbstractPropertySelectionModel.java:89)
>>
>>    * ... 112 more
>>
>>
>> Best regards
>> Ken in nashua
>>
>>
>>
>>  > Date: Tue, 1 Jul 2008 19:55:43 -0300
>>  > From: pablo.grana@...
>>  > To: users@...
>>  > Subject: Re: [trails-users] list + search
>>  >
>>  > Here is a way to reproduce it. Attached is a diff that simply adds the
>> search
>>  > trails:SearchForm component to the list page.
>>  >
>>  > To see the problem, log in and go to the 'List Team Years' menu link.
>> In the
>>  > Year Start field enter a number. You will see that the list is
>> correctly
>>  > filtered after 'search', but the form is cleared.
>>  >
>>  > If you now enter a value in the 'Year End' field and click search, both
>> 'Year
>>  > Start' and 'Year End' are filled with the same value. The result of the
>> search
>>  > is correct.
>>  >
>>  > IFAIK, the implementation of the SearchForm does not store what the
>> user
>>  > entered. it just uses the data to create a criterion and then stores it
>> in the
>>  > component 'value' field. Once the second form field (ie: 'Year End') is
>>  > processed (in a rewind), trails picks the same block object and sets
>> the value
>>  > to the value entered in that field. Then, (when not rewinding but
>> rendering),
>>  > trails draws the 'Year Start' field, using the same block that now
>> contains the
>>  > value of the 'Year End' field.
>>  >
>>  > Note: this is against trails svn trunk (1.2-SNAPSHOT).
>>  >
>>  > Hope this helps ...
>>  >
>>  > regards.
>>  >
>>  > Alejandro Scandroli wrote:
>>  > > Hi Pablo
>>  > >
>>  > > I'm sorry but I'm not following. Did you mean that your search form
>>  > > it's always being cleared; it's never being cleared, or it's
>>  > > "randomly" being cleared.
>>  > > Can you show me your code?
>>  > >
>>  > > Saludos.
>>  > > Alejandro.
>>  > >
>>  > > On Mon, Jun 30, 2008 at 4:06 PM, Pablo Gra~na
>> <pablo.grana@...> wrote:
>>  > >> Hi there.
>>  > >>
>>  > >> I want the search form at the top of the list of entities. Is there
>> an easy
>>  > >> way? I put the search component in the DefaultList.html, but it
>> works
>>  > >> partially: when the form is recreated, the status of the search page
>> fields
>>  > >> are correctly restored, neither cleaned: some values are overwriten
>> with the
>>  > >> values in other forms.
>>  > >>
>>  > >> I know close to nothing about tapestry, but I imagine that the
>> problem is in
>>  > >> the way the value for the input tag is handled: instead of storing
>> the value
>>  > >> in the page, the search component is used to create a new criterion
>> and
>>  > >> reused for the next input tag.
>>  > >>
>>  > >> I am now hacking a bit (with trails 1.1.1, unfortunately), but I
>> will
>>  > >> probably spend some time to get this working for other projects
>> using a
>>  > >> 1.2-SNAPSHOT. Any hints?
>>  > >>
>>  > >> thanks a lot.
>>  > >>
>>  > >>
>>  > >>
>> ---------------------------------------------------------------------
>>  > >> To unsubscribe from this list, please visit:
>>  > >>
>>  > >> http://xircles.codehaus.org/manage_email
>>  > >>
>>  > >>
>>  > >>
>>  > >
>>  > > ---------------------------------------------------------------------
>>  > > To unsubscribe from this list, please visit:
>>  > >
>>  > > http://xircles.codehaus.org/manage_email
>>  > >
>>  > >
>>  >
>>  > --
>>  > Pablo Gra\~na
>>  > Chief Architect
>>  > Globant
>>  > Arg Office: +54 (11) 4109 1743
>>  > UK Office: +44 (20) 7043 8269 int 8043
>>  > US Office: +1 (212) 400 7686 int 8043
>>  >
>>
>> ------------------------------------------------------------------------
>> Do more with your photos with Windows Live Photo Gallery. Get Windows
>> Live-Free
>> <http://www.windowslive.com/share.html?ocid=TXT_TAGLM_Wave2_photos_022008>
>> ------------------------------------------------------------------------
>> Do more with your photos with Windows Live Photo Gallery. Get Windows
>> Live-Free
>> <http://www.windowslive.com/share.html?ocid=TXT_TAGLM_Wave2_photos_022008>
>
> --
> Pablo Gra\~na
> Chief Architect
> Globant
> Arg Office: +54 (11) 4109 1743
> UK  Office: +44 (20) 7043 8269 int 8043
> US  Office: +1 (212) 400 7686 int 8043
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

SimpleSearchField.patch (1K) Download Attachment

 « Return to Thread: list + search