Tapestry
  1. Tapestry
  2. TAPESTRY-1076

Wraped form components can't be attached to FieldLabels

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.1
    • Fix Version/s: 4.1.1
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      I have a component witch wraps a tapestry "TextField".
      Something like this just as an example...

      .html

      <html>
      <body jwcid="$content$">
      <input jwcid="inputtext@TextField"/>
      </body>
      </html>

      .jwc

      <?xml version="1.0"?>
      <!DOCTYPE component-specification PUBLIC
      "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
      "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
      <component-specification allow-body="no" allow-informal-parameters="yes">
      </component-specification>

      If I use this component with a Label in a form like this...

      <form jwcid="form@Form">
      <label jwcid="@FieldLabel" field="component:comp1"/>
      <input jwcid="comp1@myTextField" displayName="Field description" value="ognl:data" />
      </form>

      I get the following error:

      "org.apache.tapestry.BindingException
      Error converting value for template parameter field: No type converter for type org.apache.tapestry.form.IFormComponent is available."

      Seems like it need the form component and is trying to get it as the parent of the inner TextField component, witch is not the form but my wrapper component. At least this is my guess.

      The full stacktrace...

      • org.apache.tapestry.coerce.ValueConverterImpl.coerceValue(ValueConverterImpl.java:105)
      • $ValueConverter_10d41ea6164.coerceValue($ValueConverter_10d41ea6164.java)
      • org.apache.tapestry.binding.AbstractBinding.getObject(AbstractBinding.java:91)
      • $FieldLabel_330.getField($FieldLabel_330.java)
      • org.apache.tapestry.valid.FieldLabel.renderComponent(FieldLabel.java:52)
      • org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:676)
      • org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:131)
      • org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:491)
      • org.apache.tapestry.components.RenderBody.renderComponent(RenderBody.java:41)
      • org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:676)
      • org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:131)
      • org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:491)
      • org.apache.tapestry.form.FormSupportImpl.render(FormSupportImpl.java:495)
      • org.apache.tapestry.form.Form.renderComponent(Form.java:219)
      • org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:676)
      • org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:131)
      • org.apache.tapestry.BaseComponent.renderComponent(BaseComponent.java:92)
      • org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:676)
      • org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:131)
      • org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:491)
      • org.apache.tapestry.components.RenderBody.renderComponent(RenderBody.java:41)
      • org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:676)
      • org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:131)
      • org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:491)
      • org.apache.tapestry.html.Body.renderComponent(Body.java:151)
      • org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:676)
      • org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:131)
      • org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:491)
      • org.apache.tapestry.html.Shell.renderComponent(Shell.java:64)
      • org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:676)
      • org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:131)
      • org.apache.tapestry.BaseComponent.renderComponent(BaseComponent.java:92)
      • org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:676)
      • org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:131)
      • org.apache.tapestry.BaseComponent.renderComponent(BaseComponent.java:92)
      • org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:676)
      • org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:129)
      • org.apache.tapestry.AbstractPage.renderPage(AbstractPage.java:248)
      • org.apache.tapestry.engine.RequestCycle.renderPage(RequestCycle.java:402)
      • org.apache.tapestry.services.impl.DefaultResponseBuilder.renderResponse(DefaultResponseBuilder.java:117)
      • org.apache.tapestry.services.impl.ResponseRendererImpl.renderResponse(ResponseRendererImpl.java:33)
      • $ResponseRenderer_10d41ea6195.renderResponse($ResponseRenderer_10d41ea6195.java)
      • $ResponseRenderer_10d41ea6194.renderResponse($ResponseRenderer_10d41ea6194.java)
      • org.apache.tapestry.engine.HomeService.service(HomeService.java:68)
      • $IEngineService_10d41ea61fc.service($IEngineService_10d41ea61fc.java)
      • org.apache.tapestry.services.impl.EngineServiceInnerProxy.service(EngineServiceInnerProxy.java:77)
      • org.apache.tapestry.services.impl.EngineServiceOuterProxy.service(EngineServiceOuterProxy.java:72)
      • org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:241)
      • org.apache.tapestry.services.impl.InvokeEngineTerminator.service(InvokeEngineTerminator.java:60)
      • $WebRequestServicer_10d41ea61dd.service($WebRequestServicer_10d41ea61dd.java)
      • $WebRequestServicer_10d41ea61dc.service($WebRequestServicer_10d41ea61dc.java)
      • $WebRequestServicer_10d41ea61d9.service($WebRequestServicer_10d41ea61d9.java)
      • $WebRequestServicer_10d41ea61d8.service($WebRequestServicer_10d41ea61d8.java)
      • org.apache.tapestry.services.impl.WebRequestServicerPipelineBridge.service(WebRequestServicerPipelineBridge.java:56)
      • $ServletRequestServicer_10d41ea61bf.service($ServletRequestServicer_10d41ea61bf.java)
      • $ServletRequestServicer_10d41ea61be.service($ServletRequestServicer_10d41ea61be.java)
      • org.apache.tapestry.request.DecodedRequestInjector.service(DecodedRequestInjector.java:55)
      • $ServletRequestServicerFilter_10d41ea61bb.service($ServletRequestServicerFilter_10d41ea61bb.java)
      • $ServletRequestServicerFilter_10d41ea61ba.service($ServletRequestServicerFilter_10d41ea61ba.java)
      • $ServletRequestServicer_10d41ea61c0.service($ServletRequestServicer_10d41ea61c0.java)
      • org.apache.tapestry.multipart.MultipartDecoderFilter.service(MultipartDecoderFilter.java:52)
      • $ServletRequestServicerFilter_10d41ea61b9.service($ServletRequestServicerFilter_10d41ea61b9.java)
      • $ServletRequestServicerFilter_10d41ea61b8.service($ServletRequestServicerFilter_10d41ea61b8.java)
      • $ServletRequestServicer_10d41ea61c0.service($ServletRequestServicer_10d41ea61c0.java)
      • org.apache.tapestry.services.impl.SetupRequestEncoding.service(SetupRequestEncoding.java:53)
      • $ServletRequestServicerFilter_10d41ea61bd.service($ServletRequestServicerFilter_10d41ea61bd.java)
      • $ServletRequestServicerFilter_10d41ea61bc.service($ServletRequestServicerFilter_10d41ea61bc.java)
      • $ServletRequestServicer_10d41ea61c0.service($ServletRequestServicer_10d41ea61c0.java)
      • $ServletRequestServicer_10d41ea61b3.service($ServletRequestServicer_10d41ea61b3.java)
      • $ServletRequestServicer_10d41ea61b2.service($ServletRequestServicer_10d41ea61b2.java)
      • org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:123)
      • org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:104)
      • javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
      • javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      • org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      • org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      • org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      • org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      • org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      • org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      • org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      • org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      • org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
      • org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      • org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      • org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      • org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      • org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      • org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      • org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      • org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      • org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      • java.lang.Thread.run(Thread.java:595)

      If a full test case is required I could provide one.

        Activity

        Hide
        Pedro Viegas added a comment -

        BTW: This is converted code from Tap 4.0 and it worked fine then.

        Show
        Pedro Viegas added a comment - BTW: This is converted code from Tap 4.0 and it worked fine then.
        Hide
        Jesse Kuhnert added a comment -

        Need more contextual information.

        Can you put in what your component template looks like exactly? Maybe a test class would help.

        Show
        Jesse Kuhnert added a comment - Need more contextual information. Can you put in what your component template looks like exactly? Maybe a test class would help.
        Hide
        Norbert Sándor added a comment -

        I think that such problems should be discussed on the user mailing list first, not immediately on the JIRA.

        Your problem is that @FieldLabel's "field" is of type IFormComponent but you try to pass a BaseComponent to it. That's why you get the exception because BaseComponent doesn't implement IFormComponent.

        Try something like:

        <form jwcid="form@Form">
        <label jwcid="@FieldLabel" field="ognl:comp1.components.TEXTFIELD"/>
        <input jwcid="comp1@myTextField" displayName="Field description" value="ognl:data" />
        </form>

        where TEXTFIELD is the ID of the @TextField component in your custom @myTextField component (I guess this @myTextField is the same component as in your previous jira post).

        Or - this is what I'm doing in my applications - subclass TextField instead of embedding it into a custom component.

        Regards,
        Norbi

        Show
        Norbert Sándor added a comment - I think that such problems should be discussed on the user mailing list first, not immediately on the JIRA. Your problem is that @FieldLabel's "field" is of type IFormComponent but you try to pass a BaseComponent to it. That's why you get the exception because BaseComponent doesn't implement IFormComponent. Try something like: <form jwcid="form@Form"> <label jwcid="@FieldLabel" field="ognl:comp1.components.TEXTFIELD"/> <input jwcid="comp1@myTextField" displayName="Field description" value="ognl:data" /> </form> where TEXTFIELD is the ID of the @TextField component in your custom @myTextField component (I guess this @myTextField is the same component as in your previous jira post). Or - this is what I'm doing in my applications - subclass TextField instead of embedding it into a custom component. Regards, Norbi
        Hide
        Norbert Sándor added a comment -

        Are you sure that this worked in tap4?
        I may be wrong but I'm almost sure it did not...

        Show
        Norbert Sándor added a comment - Are you sure that this worked in tap4? I may be wrong but I'm almost sure it did not...
        Hide
        Pedro Viegas added a comment -

        Several comment in order...

        1st of all, you're right, this sould of course had been discussed in the list first. I was sure it was a bug and got ahead of myself! Sorry.
        2nd, you're again right, this did not worked in Tap4, I did not use the FieldLabal before, did use everything else but not the FieldLabel. Sorry, my mistake again, was really sure I did

        Now to what matters. Tried what you said and works. I understand the bahaviour now. I will reimplement all my embeded components like you said, throught subclassing and not enbedding, but the workarround you said works.

        Thanks and again Sorry, will post to the mailing list before.

        To close this issue this IS an invalid BUG. Shame on me!

        Show
        Pedro Viegas added a comment - Several comment in order... 1st of all, you're right, this sould of course had been discussed in the list first. I was sure it was a bug and got ahead of myself! Sorry. 2nd, you're again right, this did not worked in Tap4, I did not use the FieldLabal before, did use everything else but not the FieldLabel. Sorry, my mistake again, was really sure I did Now to what matters. Tried what you said and works. I understand the bahaviour now. I will reimplement all my embeded components like you said, throught subclassing and not enbedding, but the workarround you said works. Thanks and again Sorry, will post to the mailing list before. To close this issue this IS an invalid BUG. Shame on me!
        Hide
        Norbert Sándor added a comment -

        No problem
        I'm glad that I could help!

        Regards,
        Norbi

        Show
        Norbert Sándor added a comment - No problem I'm glad that I could help! Regards, Norbi
        Hide
        Jesse Kuhnert added a comment -

        Regardless of the ultimate validity of the component type passed into the parameter the error message presented is extremely deceptive.

        I've fixed this now to tell you what you gave it and what it wanted.. This is definitely one of those "quircks" we can do without.

        Thanks for reporting it!

        Show
        Jesse Kuhnert added a comment - Regardless of the ultimate validity of the component type passed into the parameter the error message presented is extremely deceptive. I've fixed this now to tell you what you gave it and what it wanted.. This is definitely one of those "quircks" we can do without. Thanks for reporting it!
        Hide
        Pedro Viegas added a comment -

        Thanks!

        Show
        Pedro Viegas added a comment - Thanks!

          People

          • Assignee:
            Jesse Kuhnert
            Reporter:
            Pedro Viegas
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development