Tapestry
  1. Tapestry
  2. TAPESTRY-1731

@Inject @Symbol does not work inside a component

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.5
    • Fix Version/s: 5.0.6
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      This should work:

      @Inject
      @Symbol(WebConstants.DOCUMENT_ROOT_DIR)
      private String _documentRoot;

      But the @Symbol is not recognized, so the injection is implemented as:

      add method: private void _$write_documentRoot(java.lang.String $1)
      throw new java.lang.RuntimeException("Field com.dtsoft.ws.web.pages.CreateOrder._documentRoot is read-only.");

      add constructor: com.dtsoft.ws.web.pages.CreateOrder(org.apache.tapestry.internal.InternalComponentResources $1, com.dtsoft.ws.web.services.OrderDatabase $2)

      { _$resources = $1; _documentRoot = _$resources.getCompleteId(); _database = $2; initializer(); }

      This appears to be the same for @Inject @Value ... with a String type, the only thing that can be injected is the component id.

        Activity

        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12568297 ] jira [ 12591363 ]
        Mark Thomas made changes -
        Workflow jira [ 12411966 ] Default workflow, editable Closed status [ 12568297 ]
        Howard M. Lewis Ship made changes -
        Fix Version/s 5.0.6 [ 12312544 ]
        Status Open [ 1 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]
        Hide
        Howard M. Lewis Ship added a comment -

        This is a nasty conflict between InjectWorker and InjectResourcesWorker.

        InjectResourcesWorker comes first, sees the @Inject on type String and takes over, injecting the component id.

        What it should do is (somehow) recognize the @Symbol (or @Value) annotation, and defer to InjectWorker.

        Only if InjectWorker fails to perform an injection should InjectResourcesWorker be given a crack.

        However, if InjectWorker is scheduled first, then it will fail for common types such as ComponentResources.

        This will require an API change to ObjectProvider, to allow it to NOT fail if no match may be found.

        Show
        Howard M. Lewis Ship added a comment - This is a nasty conflict between InjectWorker and InjectResourcesWorker. InjectResourcesWorker comes first, sees the @Inject on type String and takes over, injecting the component id. What it should do is (somehow) recognize the @Symbol (or @Value) annotation, and defer to InjectWorker. Only if InjectWorker fails to perform an injection should InjectResourcesWorker be given a crack. However, if InjectWorker is scheduled first, then it will fail for common types such as ComponentResources. This will require an API change to ObjectProvider, to allow it to NOT fail if no match may be found.
        Howard M. Lewis Ship made changes -
        Field Original Value New Value
        Assignee Howard M. Lewis Ship [ hlship ]
        Howard M. Lewis Ship created issue -

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Howard M. Lewis Ship
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development