MyFaces Core
  1. MyFaces Core
  2. MYFACES-2598

UIViewParameter does not get an automatic id

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-beta-3
    • Fix Version/s: 2.0.0-beta-3
    • Component/s: None
    • Labels:
      None

      Description

      You see the fancy missing id warning when using f:viewParam:

      10.03.2010 13:35:36 javax.faces.component.UIComponentBase getClientId
      WARNUNG: WARNING: Component j_id12 just got an automatic id, because there was no id assigned yet. If this component was created dynamically (i.e. not by a JSP tag) you should assign it an explicit static id or assign it the id you get from the createUniqueId from the current UIViewRoot component right after creation! Path to Component:

      {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /viewparam.xhtml][Class: javax.faces.component.UIPanel,Id: javax_faces_metadata][Class: javax.faces.component.UIViewParameter,Id: j_id12]}
      1. viewparam.xhtml
        0.6 kB
        Jakob Korherr

        Activity

        Hide
        Jakob Korherr added a comment -

        The problem is that at the time the UIViewParameter component is created there seems to be no UniqueIdVendor available yet.

        Show
        Jakob Korherr added a comment - The problem is that at the time the UIViewParameter component is created there seems to be no UniqueIdVendor available yet.
        Hide
        Leonardo Uribe added a comment -

        pushUniqueIdVendorToStack should be called from ComponentTagHandlerDelegate, not from DefaultFacelet. This code should be reverted. Really that warning is becoming nasty and starting to have no sense, because it is common to create components without any explicit id. I'll comment that one and rever the changes.

        Show
        Leonardo Uribe added a comment - pushUniqueIdVendorToStack should be called from ComponentTagHandlerDelegate, not from DefaultFacelet. This code should be reverted. Really that warning is becoming nasty and starting to have no sense, because it is common to create components without any explicit id. I'll comment that one and rever the changes.
        Hide
        Jakob Korherr added a comment -

        Leonardo,

        UIViewParameter has to get a valid clientId here, otherwise the state saving for the parameter does not work correctly and this causes the problem that you are not able to use postbacks on a view with at least one required UIViewParameter.

        I first reopened MYFACES-2592, because I thought this was the problem, but it turns out that this issue is the problem.

        Show
        Jakob Korherr added a comment - Leonardo, UIViewParameter has to get a valid clientId here, otherwise the state saving for the parameter does not work correctly and this causes the problem that you are not able to use postbacks on a view with at least one required UIViewParameter. I first reopened MYFACES-2592 , because I thought this was the problem, but it turns out that this issue is the problem.
        Hide
        Jakob Korherr added a comment -

        In ComponentTagHandlerDelegate the UniqueIdVendor is retrieved by the following code:

        UniqueIdVendor uniqueIdVendor = actx.getUniqueIdVendorFromStack();
        if (uniqueIdVendor == null)

        { uniqueIdVendor = facesContext.getViewRoot(); }

        But at the first time we get there for a UIViewParameter, there is no UniqueIdVendor on the stack and facesContext.getViewRoot() returns null, because it is set later. So we either have to push the UIViewRoot to the stack in DefaultFacelet or check for the parent here too. Because you reverted my changes for this in DefaultFacelet I will introduce a check for the parent as a UniqueIdVendor in ComponentTagHandlerDelegate. Maybe that's better!

        Show
        Jakob Korherr added a comment - In ComponentTagHandlerDelegate the UniqueIdVendor is retrieved by the following code: UniqueIdVendor uniqueIdVendor = actx.getUniqueIdVendorFromStack(); if (uniqueIdVendor == null) { uniqueIdVendor = facesContext.getViewRoot(); } But at the first time we get there for a UIViewParameter, there is no UniqueIdVendor on the stack and facesContext.getViewRoot() returns null, because it is set later. So we either have to push the UIViewRoot to the stack in DefaultFacelet or check for the parent here too. Because you reverted my changes for this in DefaultFacelet I will introduce a check for the parent as a UniqueIdVendor in ComponentTagHandlerDelegate. Maybe that's better!
        Hide
        Jakob Korherr added a comment -

        You can use this facelet page to test this one.

        The view needs the required view parameter "input", which you have to provide via the URL. If you provided it once, you can hit the button on the page again and again and there won't be validation errors, altought the parameter is not present in the URL anymore, because the parameter was specified at the first request.

        Show
        Jakob Korherr added a comment - You can use this facelet page to test this one. The view needs the required view parameter "input", which you have to provide via the URL. If you provided it once, you can hit the button on the page again and again and there won't be validation errors, altought the parameter is not present in the URL anymore, because the parameter was specified at the first request.
        Hide
        Jakob Korherr added a comment -

        After discussing this one with Leonardo, we agreed that it is better to add the code in DefaultFacelet too, because there could be some scenarios where the solution in ComponentTagHandlerDelegate isn't enough.

        Show
        Jakob Korherr added a comment - After discussing this one with Leonardo, we agreed that it is better to add the code in DefaultFacelet too, because there could be some scenarios where the solution in ComponentTagHandlerDelegate isn't enough.

          People

          • Assignee:
            Jakob Korherr
            Reporter:
            Jakob Korherr
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development