Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.9m9
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Myfaces fails to restore a view it it uses aliases in bindings.

      Our jsf looks like this (for sure, we use include for the dataTable):

      <x:aliasBeansScope>
      <x:aliasBean alias="#

      {coTopicEdit}

      " value="#

      {coAddressEdit}

      " />
      <h:dataTable var="topic" value="#

      {coTopicEdit.topics}

      "
      binding="#

      {coTopicEdit.genericTopicTable}" >
      ....
      </h:dataTable>
      <h:commandLink value="xx"/>
      </x:aliasBeansScope>


      The page renders correctly for the first time, but if you press the commandLink myfaces fails in the restoreView phase.
      The reason is simple:
      During LifecycleImpl.restoreView myfaces tries to attach each component to the backing bean (in recursivelyHandleComponentReferencesAndSetValid - "binding.setValue").
      Now if it comes to the binding of the dataTable the alias bean havent had the chance to reassign its alias and thus the ValueBinding for "#{coTopicEdit.genericTopicTable}

      " fails.

      To workaround it I create my own ViewHandler (code follows).
      I hooked into restoreView - process the view recursivley and call "makeAlias" on each alias bean using reflection (the method is package private).
      This IS a hack and (I think) it breaks the scope of the alias , but for now I am happy with it.

      Any ideas how to solve it correctly?

      And now the code in case someone else needs it too:

      public UIViewRoot restoreView(FacesContext facesContext, String viewId)
      {
      UIViewRoot root = super.restoreView(facesContext, viewId);
      if (root != null)

      { processAliases(facesContext, root); }

      return root;
      }

      protected void processAliases(FacesContext context, UIComponent root)
      {
      if (root == null)

      { return; }

      for (Iterator it = root.getFacetsAndChildren(); it.hasNext(); )
      {
      UIComponent component = (UIComponent)it.next();

      if (component instanceof AliasBean)
      {
      AliasBean alias = (AliasBean) component;
      try

      { Method makeAliasMethod = alias.getClass().getDeclaredMethod("makeAlias", FacesContext.class); makeAliasMethod.setAccessible(true); makeAliasMethod.invoke(alias, context); }

      catch (NoSuchMethodException e)

      { log.warn(e.getLocalizedMessage(), e); }
      catch (IllegalAccessException e)
      { log.warn(e.getLocalizedMessage(), e); }

      catch (InvocationTargetException e)

      { log.warn(e.getLocalizedMessage(), e); }

      }

      processAliases(context, component);
      }
      }

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        13d 9h 8m 1 Mathias Broekelmann 29/Jul/05 01:04
        Closed Closed Reopened Reopened
        210d 17h 31m 1 Mario Ivankovits 24/Feb/06 17:35
        Reopened Reopened Patch Available Patch Available
        11d 6h 8m 1 07/Mar/06 23:43
        Patch Available Patch Available Resolved Resolved
        17m 12s 1 Mario Ivankovits 08/Mar/06 00:00
        Resolved Resolved Closed Closed
        7s 1 Mario Ivankovits 08/Mar/06 00:01
        sean schofield made changes -
        Workflow  MyFaces Workflow [ 12359491 ] MyFaces Workflow2 [ 12360080 ]
        sean schofield made changes -
        Workflow  MyFaces Workflow [ 12358890 ] MyFaces Workflow2 [ 12359491 ]
        sean schofield made changes -
        Workflow  MyFaces Workflow [ 12358441 ] MyFaces Workflow2 [ 12358890 ]
        sean schofield made changes -
        Workflow  MyFaces Workflow [ 12357388 ] MyFaces Workflow2 [ 12358441 ]
        sean schofield made changes -
        Workflow MyFaces Workflow2 [ 12355682 ]  MyFaces Workflow [ 12357388 ]
        sean schofield made changes -
        Workflow MyFaces Workflow [ 12354160 ] MyFaces Workflow2 [ 12355682 ]
        sean schofield made changes -
        Workflow MyFaces Workflow2 [ 12349292 ] MyFaces Workflow [ 12354160 ]
        Mario Ivankovits made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mario Ivankovits made changes -
        Resolution Fixed [ 1 ]
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Anonymous made changes -
        Status Reopened [ 4 ] Patch Available [ 10002 ]
        sean schofield made changes -
        Workflow MyFaces Workflow [ 12348012 ] MyFaces Workflow2 [ 12349292 ]
        sean schofield made changes -
        Workflow MyFaces Workflow [ 12348012 ] MyFaces Workflow2 [ 12349201 ]
        sean schofield made changes -
        Workflow MyFaces Workflow [ 12348012 ] MyFaces Workflow2 [ 12349162 ]
        Mario Ivankovits made changes -
        Assignee Mario Ivankovits [ imario ] Martin Marinschek [ mmarinschek ]
        Mario Ivankovits made changes -
        Assignee Mario Ivankovits [ imario ]
        Status Closed [ 6 ] Reopened [ 4 ]
        Resolution Won't Fix [ 2 ]
        sean schofield made changes -
        Workflow jira [ 12322295 ] MyFaces Workflow [ 12348012 ]
        Mathias Broekelmann made changes -
        Field Original Value New Value
        Resolution Won't Fix [ 2 ]
        Status Open [ 1 ] Closed [ 6 ]
        Hide
        Mathias Broekelmann added a comment -

        component bindings are resolved at creation time of the component and is out of scope of the alias bean component. JSF allows you to create only one component instance for one jsf tag.

        If you just need to access the component instance try to use a managed bean which acts as an interface between the component and the aliased bean. The component instance is stored in the non aliased bean and the aliased bean uses the non aliased bean to access the component instance.

        Hope that helps.

        Show
        Mathias Broekelmann added a comment - component bindings are resolved at creation time of the component and is out of scope of the alias bean component. JSF allows you to create only one component instance for one jsf tag. If you just need to access the component instance try to use a managed bean which acts as an interface between the component and the aliased bean. The component instance is stored in the non aliased bean and the aliased bean uses the non aliased bean to access the component instance. Hope that helps.
        Mario Ivankovits created issue -

          People

          • Assignee:
            Martin Marinschek
            Reporter:
            Mario Ivankovits
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development