ICEfaces
  1. ICEfaces
  2. ICE-3667

Multiple instances of outputResource do not work correctly together

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.2
    • Fix Version/s: 1.7.2 SP1, 1.8DR#2, 1.8
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      All

      Description

      A customer is facing a similar issue to the one described in forum post http://www.icefaces.org/JForum/posts/list/10113.page . The customer has described his issue as:

      "Even though at render time 2 different resource objects are instantiated with different parameters, when I click on the button intended to retrieve the particular resource , one resource is actually retrieved independent of which button I click on..."

      I've run the sample war in the forum post and have confirmed the issue. Nothing in their code looks out of the ordinary. Attached is the war file ready to be deployed on Jboss 4.2.2.

      http://localhost:8080/OutputResource/table.iface

      1. OutputResource.java
        9 kB
        Tyler Johnson

        Issue Links

          Activity

          Hide
          Tyler Johnson added a comment -

          Customer has just reported the following:

          BEGIN: The problem appears to lie in following:

          In the datatable the

          <ice:column>
          <ice:outputResource>

          combination appears to show in OutputResourceRenderer

          String clientId = uiComponent.getClientId(facesContext);
          OutputResource outputResource = (OutputResource) uiComponent;

          shows the uiComponent being the same each time the renderer is called, with clientId different on each row. The uiComponent is not safe to use as a singleton since

          public Resource getResource() {
          ValueBinding vb = getValueBinding("resource");
          resource = (Resource) vb.getValue(getFacesContext());

          Where resource is a private member which is then used later in the code in the within Resource r = new Resource() {

          To work around the issue until you can resolve it, I have introducted some code enclosed which appears to resolve issue. See internalResource variable.. It is probably now the most optimal way to resolve issue but it works..

          END

          Show
          Tyler Johnson added a comment - Customer has just reported the following: BEGIN: The problem appears to lie in following: In the datatable the <ice:column> <ice:outputResource> combination appears to show in OutputResourceRenderer String clientId = uiComponent.getClientId(facesContext); OutputResource outputResource = (OutputResource) uiComponent; shows the uiComponent being the same each time the renderer is called, with clientId different on each row. The uiComponent is not safe to use as a singleton since public Resource getResource() { ValueBinding vb = getValueBinding("resource"); resource = (Resource) vb.getValue(getFacesContext()); Where resource is a private member which is then used later in the code in the within Resource r = new Resource() { To work around the issue until you can resolve it, I have introducted some code enclosed which appears to resolve issue. See internalResource variable.. It is probably now the most optimal way to resolve issue but it works.. END
          Hide
          Tyler Johnson added a comment -

          OutputResource.war

          Show
          Tyler Johnson added a comment - OutputResource.war
          Hide
          Tyler Johnson added a comment -

          OutputResource.java

          Show
          Tyler Johnson added a comment - OutputResource.java
          Hide
          Philip Breau added a comment -

          I'm not sure if this is the root of problem, but I had changed the getResource() method on the component to actually first check the value binding and set the instance variable off of that to avoid this issue:

          http://jira.icefaces.org/browse/ICE-2348#action_22973

          public Resource getResource() {
          ValueBinding vb = getValueBinding("resource");
          resource = (Resource) vb.getValue(getFacesContext());
          ...

          Show
          Philip Breau added a comment - I'm not sure if this is the root of problem, but I had changed the getResource() method on the component to actually first check the value binding and set the instance variable off of that to avoid this issue: http://jira.icefaces.org/browse/ICE-2348#action_22973 public Resource getResource() { ValueBinding vb = getValueBinding("resource"); resource = (Resource) vb.getValue(getFacesContext()); ...
          Hide
          Adnan Durrani added a comment -

          After debugging the code I found out that the problem is due to the reason that "clicking" on the "resource" link, works as request/response mechanism and it doesn't involve JSF Life cycle at all. So the dataTable does not have chance to load the proper row object into the scope.

          The OuputResource component uses inner class to define the resource, so to responds the request the ResourceDispatcher invokes the "open" method on the "resource", which uses the reference of the most recently evaluated "resource" object by the outputResource component. That is why every link inside the table brings the same resource and that obviously for the last row of the dataTable.

          I couldn't see any straight fix to the component, it might require something to change with Resource API as well. So I am re-assigning it to Mircea.

          Show
          Adnan Durrani added a comment - After debugging the code I found out that the problem is due to the reason that "clicking" on the "resource" link, works as request/response mechanism and it doesn't involve JSF Life cycle at all. So the dataTable does not have chance to load the proper row object into the scope. The OuputResource component uses inner class to define the resource, so to responds the request the ResourceDispatcher invokes the "open" method on the "resource", which uses the reference of the most recently evaluated "resource" object by the outputResource component. That is why every link inside the table brings the same resource and that obviously for the last row of the dataTable. I couldn't see any straight fix to the component, it might require something to change with Resource API as well. So I am re-assigning it to Mircea.
          Hide
          Adnan Durrani added a comment -

          trunk revision : 17820

          Even though there is a single instance of the outputResource component when inside the dataTable, but there are designated resource objects for each resource, that allowed to fix this issue at the component level. The fix is to not to update the reference of instance member of its parent class, use the value binding instead.

          Show
          Adnan Durrani added a comment - trunk revision : 17820 Even though there is a single instance of the outputResource component when inside the dataTable, but there are designated resource objects for each resource, that allowed to fix this issue at the component level. The fix is to not to update the reference of instance member of its parent class, use the value binding instead.
          Hide
          Adnan Durrani added a comment -

          Branch 1.7 : revision 17830

          Show
          Adnan Durrani added a comment - Branch 1.7 : revision 17830

            People

            • Assignee:
              Unassigned
              Reporter:
              Tyler Johnson
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: