[
https://issues.apache.org/jira/browse/TAPESTRY-2430?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12606487#action_12606487
]
Howard M. Lewis Ship commented on TAPESTRY-2430:
------------------------------------------------
I think I understand what's going on here.
It's a difficult nut to crack, because of how Tapestry handles form submissions.
Inside the form submission, in a hidden field, is a stream of Java objects
(serialized, gzipped, MIME encoded) to tell the framework how to handle the
submission. This is a replacement for T4's fragile "rewind cycle".
It works very well for "flat" forms, as the Java objects identify exactly which
components are to be activated to handle each query parameter.
For the BeanEditor, the stored objects identify which property of the bean is
being editted; objects after that will activate components to handle the
submission.
The problem is that FormFragment (and FormInjector) adds a second stream of
Java objects; this stream gets handled *after* the original stream.
That means that the context, which property is being updated, is wrong or
simply out of date by the time the commands related to the injected form
content.
It may be necessary to wrap the new content in a component that exists to
re-connect the BeanEditor with the correct active editting property. Again,
tricky.
> Context lost in a form fragment in a property editor component
> --------------------------------------------------------------
>
> Key: TAPESTRY-2430
> URL: https://issues.apache.org/jira/browse/TAPESTRY-2430
> Project: Tapestry
> Issue Type: Bug
> Components: Core Components
> Affects Versions: 5.0.12
> Reporter: José Paumard
>
> I created a PropertyEditor to edit a special class, which content spans over
> one or more pair of String.
> The TML for the PropertyEditor declaration is :
> <t:block t:id="myProp">
> <t:editor.myPropEditor t:id="myPropEditor"
>
> propertyvalue="prop:context.propertyValue"
> propertyname="prop:context.label"
>
> messages="prop:context.containerMessages"/>
> </t:block>
> The TML of the property editor itself is :
> <t:label for="s11"/> <t:textfield t:id="s12"/> <br/>
> <t:label for="s21"/> : <t:textfield t:id="s22" /> <br/>
> <t:checkbox t:id="showFragment1" t:mixins="triggerfragment"
> fragment="fragment1"/>
> <t:formfragment t:id="fragment1" visible="showFragment1">
> <t:label for="t11"/> <t:textfield t:id="t12"/> <br/>
> <t:label for="t21"/> : <t:textfield t:id="t22" /> <br/>
> </t:formfragment>
> With a basic POJO class associated to that, and the declaration of the
> parameters :
> public class MyPropertyEditor {
> @Parameter(name="propertyValue",required=true)
> private MyProperty myProperty ;
>
> @Parameter(name="propertyName",required=true)
> private String propertyName ;
>
> @Parameter(name="messages",required=true)
> private Messages messages ;
> private String s11, s12, s21, s22, t11, t12, t21, t22 ;
> ...
> }
> If I try to read / update the myPropery parameter in that class :
> - from the s11, s12, s21, s22 getter or setter -> everything works ok, I can
> read or update this parameter
> - from the t11, t12, t21 or t22 getter or setter, I get the following stack
> trace :
> An unexpected application exception has occurred.
> * org.apache.tapestry5.runtime.ComponentEventException
> Failure writing parameter 'value' of component
> AppPropertyEditBlocks:mypropertyeditor.content2: Failure reading parameter
> 'propertyValue' of component AppPropertyEditBlocks:mypropertyeditor: No
> object of type org.apache.tapestry5.services.PropertyEditContext is available
> from the Environment. Available types are
> org.apache.tapestry5.ValidationTracker,
> org.apache.tapestry5.services.ComponentEventResultProcessor,
> org.apache.tapestry5.services.FormSupport,
> org.apache.tapestry5.services.Heartbeat.
> context
> eventType
> action
> location
> classpath:org/.../webapp/components/item/AbstractCreate.tml, line
> 6, column 24
> 1 <t:container
> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> 2
> 3 ${message:title}
> 4 <br/>
> 5
> 6 <t:form t:id="create">
> 7 <t:errors/>
> 8 <t:beaneditor t:id="createEditor" object="item"
> exclude="prop:excludelist"/>
> 9 <t:submit value="message:create"/>
> 10 </t:form>
> 11
> * org.apache.tapestry5.ioc.internal.util.TapestryException
> Failure writing parameter 'value' of component
> AppPropertyEditBlocks:mypropertyeditor.content2: Failure reading parameter
> 'propertyValue' of component AppPropertyEditBlocks:mypropertyeditor: No
> object of type org.apache.tapestry5.services.PropertyEditContext is available
> from the Environment. Available types are
> org.apache.tapestry5.ValidationTracker,
> org.apache.tapestry5.services.ComponentEventResultProcessor,
> org.apache.tapestry5.services.FormSupport,
> org.apache.tapestry5.services.Heartbeat.
> location
> classpath:org/.../webapp/components/editor/MyPropertyEditor.tml,
> line 21, column 62
> 16 <t:checkbox t:id="showFragment1" t:mixins="triggerfragment"
> fragment="fragment1"/>
> 17 <t:label for="showFragment1"/>
> 18
> 19 <t:formfragment t:id="fragment1" visible="showFragment1">
> 20 <t:label for="t11"/> : <t:textfield t:id="t12"/>
> 21 <t:label for="t21"/> : <t:textfield t:id="t33" />
> 22 </t:formfragment>
> 23
> 24
> 25 </td></tr>
> 26 </table>
> * org.apache.tapestry5.ioc.internal.util.TapestryException
> Failure reading parameter 'propertyValue' of component
> AppPropertyEditBlocks:mypropertyeditor: No object of type
> org.apache.tapestry5.services.PropertyEditContext is available from the
> Environment. Available types are org.apache.tapestry5.ValidationTracker,
> org.apache.tapestry5.services.ComponentEventResultProcessor,
> org.apache.tapestry5.services.FormSupport,
> org.apache.tapestry5.services.Heartbeat.
> location
> classpath:org/.../webapp/pages/AppPropertyEditBlocks.tml, line 7,
> column 73
> 2
> 3 <t:block t:id="myproperty">
> 4 <t:editor.mypropertyeditor t:id="myPropertyEditor"
> 5 propertyvalue="prop:context.propertyValue"
> 6 propertyname="prop:context.label"
> 7 messages="prop:context.containerMessages"/>
> 8 </t:block>
> 9
> * java.lang.RuntimeException
> No object of type org.apache.tapestry5.services.PropertyEditContext is
> available from the Environment. Available types are
> org.apache.tapestry5.ValidationTracker,
> org.apache.tapestry5.services.ComponentEventResultProcessor,
> org.apache.tapestry5.services.FormSupport,
> org.apache.tapestry5.services.Heartbeat.
> Stack trace
> o
> org.apache.tapestry5.internal.services.EnvironmentImpl.peekRequired(EnvironmentImpl.java:73)
> o
> org.limc.webapp.pages.AppPropertyEditBlocks._$environment_read_context(AppPropertyEditBlocks.java)
> o
> org.limc.webapp.pages.AppPropertyEditBlocks.getContext(AppPropertyEditBlocks.java:97)
> o
> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:53)
> o
> org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.readParameter(InternalComponentResourcesImpl.java:237)
> o
> org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.readParameter(InternalComponentResourcesImpl.java:252)
> o
> org.limc.webapp.components.editor.MyPropertyEditor._$read_parameter_propertyValue(MyPropertyEditor.java)
> o
> org.limc.webapp.components.editor.MyPropertyEditor.addTextPair(MyPropertyEditor.java:111)
> o
> org.limc.webapp.components.editor.MyPropertyEditor.setContent2(MyPropertyEditor.java:220)
> o
> org.apache.tapestry5.internal.bindings.PropBinding.set(PropBinding.java:66)
> o
> org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.writeParameter(InternalComponentResourcesImpl.java:273)
> o
> org.apache.tapestry5.corelib.base.AbstractTextField._$update_parameter_value(AbstractTextField.java)
> o
> org.apache.tapestry5.corelib.base.AbstractTextField.processSubmission(AbstractTextField.java:211)
> o
> org.apache.tapestry5.corelib.base.AbstractField.processSubmission(AbstractField.java:196)
> o
> org.apache.tapestry5.corelib.base.AbstractField.access$100(AbstractField.java:33)
> o
> org.apache.tapestry5.corelib.base.AbstractField$ProcessSubmission.execute(AbstractField.java:103)
> o
> org.apache.tapestry5.corelib.base.AbstractField$ProcessSubmission.execute(AbstractField.java:97)
> o
> org.apache.tapestry5.corelib.components.Form.executeStoredActions(Form.java:396)
> o
> org.apache.tapestry5.corelib.components.Form._$advised$onAction(Form.java:315)
> o
> org.apache.tapestry5.corelib.components.Form$onAction$invocation_11a730bb10b.invokeAdvisedMethod(Form$onAction$invocation_11a730bb10b.java)
> o
> org.apache.tapestry5.internal.services.AbstractComponentMethodInvocation.proceed(AbstractComponentMethodInvocation.java:71)
> o
> org.apache.tapestry5.ioc.internal.services.LoggingAdvice.advise(LoggingAdvice.java:37)
> o
> org.apache.tapestry5.internal.transform.LogWorker$1.advise(LogWorker.java:54)
> o
> org.apache.tapestry5.internal.services.AbstractComponentMethodInvocation.proceed(AbstractComponentMethodInvocation.java:80)
> o
> org.apache.tapestry5.corelib.components.Form.onAction(Form.java)
> o
> org.apache.tapestry5.corelib.components.Form.dispatchComponentEvent(Form.java)
> o
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:872)
> o
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1025)
> o
> org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:67)
> o
> org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42)
> o
> org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42)
> o
> org.apache.tapestry5.services.TapestryModule$37.handle(TapestryModule.java:1987)
> o
> org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:135)
> o
> org.apache.tapestry5.services.TapestryModule$12.service(TapestryModule.java:938)
> o
> org.limc.webapp.services.AppModule$3.service(AppModule.java:148)
> o
> org.limc.webapp.services.AppModule$1.service(AppModule.java:45)
> o
> org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42)
> o
> org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:586)
> o
> org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
> o
> org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79)
> o
> org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93)
> o
> org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84)
> o
> org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:75)
> o
> org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106)
> o
> org.apache.tapestry5.services.TapestryModule$11.service(TapestryModule.java:918)
> o
> org.apache.tapestry5.upload.internal.services.MultipartServletRequestFilter.service(MultipartServletRequestFilter.java:44)
> o
> org.limc.webapp.services.AppModule$2.service(AppModule.java:58)
> o
> org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
> o
> org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:168)
> o
> org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
> o
> org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:471)
> o
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
> o org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
> o
> org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:633)
> o org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
> o org.mortbay.http.HttpServer.service(HttpServer.java:909)
> o
> org.mortbay.http.HttpConnection.service(HttpConnection.java:820)
> o
> org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986)
> o
> org.mortbay.http.HttpConnection.handle(HttpConnection.java:837)
> o
> org.mortbay.http.SocketListener.handleConnection(SocketListener.java:245)
> o
> org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
> o
> org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]