You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Martin Kočí (JIRA)" <de...@myfaces.apache.org> on 2011/02/07 12:07:30 UTC

[jira] Created: (MYFACES-3033) Improve DebugPhaseListener for UIData and SKIP_ITERATION

Improve DebugPhaseListener for UIData and SKIP_ITERATION
--------------------------------------------------------

                 Key: MYFACES-3033
                 URL: https://issues.apache.org/jira/browse/MYFACES-3033
             Project: MyFaces Core
          Issue Type: Improvement
          Components: General
    Affects Versions: 2.1.0
            Reporter: Martin Kočí


<h:dataTable var="row" >
  <h:column>
    <h:outputText rendered="#{bean.isRendered(row)}"

There is new VisitHint.SKIP_ITERATION in JSF 2.1. If that hint is used UIData iterate over children in "flat" manner and therefore no row is available - bean.isRendered(row) obtains null as parameter and NPE can happen. One problem in this situation is a component tree walk before RESTORE_VIEW from DebugPhaseListener:

java.lang.NullPointerException
foo.bazz.bean.isRendered
...
at org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:85)
at javax.faces.component._DeltaStateHelper.eval(_DeltaStateHelper.java:260)
at javax.faces.component.UIComponentBase.isRendered
...
at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:991)
at org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener._doTreeVisit(DebugPhaseListener.java:310)
at org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener.afterPhase(DebugPhaseListener.java:286)




-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (MYFACES-3033) Improve DebugPhaseListener for UIData and SKIP_ITERATION

Posted by "Martin Kočí (Commented JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13207962#comment-13207962 ] 

Martin Kočí commented on MYFACES-3033:
--------------------------------------

I close this issues as WONT FIX:

1) DebugPhaseListener is now off: context-param: org.apache.myfaces.DEBUG_PHASE_LISTENER=false (MYFACES-3187)
2) the problem is not easily fixable in DebugPhaseListener, because the main evaluation problem comes from javax.faces.component.UIComponent.isVisitable(VisitContext): 

if (hints.contains(VisitHint.SKIP_UNRENDERED) && !this.isRendered())

the !this.isRendered() code evaluates rendered="#{bean.isRendered(row)} and because of SKIP_ITERATION= true is row null. We cannot improve DebugPhaseListener to deal with this problem.

There is a acceptable workaround  in client code: simple not-null check:
public boolean isRendered(Object row) {
	if (row != null) {
	  // evaluate rendered with not null row
	}
	return [false|true];
}
                
> Improve DebugPhaseListener for UIData and SKIP_ITERATION
> --------------------------------------------------------
>
>                 Key: MYFACES-3033
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3033
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: General
>    Affects Versions: 2.1.0
>            Reporter: Martin Kočí
>            Assignee: Martin Kočí
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
> <h:dataTable var="row" >
>   <h:column>
>     <h:outputText rendered="#{bean.isRendered(row)}"
> There is new VisitHint.SKIP_ITERATION in JSF 2.1. If that hint is used UIData iterate over children in "flat" manner and therefore no row is available - bean.isRendered(row) obtains null as parameter and NPE can happen. One problem in this situation is a component tree walk before RESTORE_VIEW from DebugPhaseListener:
> java.lang.NullPointerException
> foo.bazz.bean.isRendered
> ...
> at org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:85)
> at javax.faces.component._DeltaStateHelper.eval(_DeltaStateHelper.java:260)
> at javax.faces.component.UIComponentBase.isRendered
> ...
> at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:991)
> at org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener._doTreeVisit(DebugPhaseListener.java:310)
> at org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener.afterPhase(DebugPhaseListener.java:286)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Resolved] (MYFACES-3033) Improve DebugPhaseListener for UIData and SKIP_ITERATION

Posted by "Martin Kočí (Resolved JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-3033?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Kočí resolved MYFACES-3033.
----------------------------------

    Resolution: Won't Fix
    
> Improve DebugPhaseListener for UIData and SKIP_ITERATION
> --------------------------------------------------------
>
>                 Key: MYFACES-3033
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3033
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: General
>    Affects Versions: 2.1.0
>            Reporter: Martin Kočí
>            Assignee: Martin Kočí
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
> <h:dataTable var="row" >
>   <h:column>
>     <h:outputText rendered="#{bean.isRendered(row)}"
> There is new VisitHint.SKIP_ITERATION in JSF 2.1. If that hint is used UIData iterate over children in "flat" manner and therefore no row is available - bean.isRendered(row) obtains null as parameter and NPE can happen. One problem in this situation is a component tree walk before RESTORE_VIEW from DebugPhaseListener:
> java.lang.NullPointerException
> foo.bazz.bean.isRendered
> ...
> at org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:85)
> at javax.faces.component._DeltaStateHelper.eval(_DeltaStateHelper.java:260)
> at javax.faces.component.UIComponentBase.isRendered
> ...
> at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:991)
> at org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener._doTreeVisit(DebugPhaseListener.java:310)
> at org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener.afterPhase(DebugPhaseListener.java:286)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] Commented: (MYFACES-3033) Improve DebugPhaseListener for UIData and SKIP_ITERATION

Posted by "Martin Kočí (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12991337#comment-12991337 ] 

Martin Kočí commented on MYFACES-3033:
--------------------------------------

Please notice that this issue is not related to new VisitHint.SKIP_ITERATION only. Originally I found this problem with RichFaces - their dataTable does this optimalization now with simple if (isRestoreViewPhase)  { visit children without iteration}

Please see https://issues.jboss.org/browse/RF-10154 for details.

> Improve DebugPhaseListener for UIData and SKIP_ITERATION
> --------------------------------------------------------
>
>                 Key: MYFACES-3033
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3033
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: General
>    Affects Versions: 2.1.0
>            Reporter: Martin Kočí
>
> <h:dataTable var="row" >
>   <h:column>
>     <h:outputText rendered="#{bean.isRendered(row)}"
> There is new VisitHint.SKIP_ITERATION in JSF 2.1. If that hint is used UIData iterate over children in "flat" manner and therefore no row is available - bean.isRendered(row) obtains null as parameter and NPE can happen. One problem in this situation is a component tree walk before RESTORE_VIEW from DebugPhaseListener:
> java.lang.NullPointerException
> foo.bazz.bean.isRendered
> ...
> at org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:85)
> at javax.faces.component._DeltaStateHelper.eval(_DeltaStateHelper.java:260)
> at javax.faces.component.UIComponentBase.isRendered
> ...
> at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:991)
> at org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener._doTreeVisit(DebugPhaseListener.java:310)
> at org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener.afterPhase(DebugPhaseListener.java:286)

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] Commented: (MYFACES-3033) Improve DebugPhaseListener for UIData and SKIP_ITERATION

Posted by "Andy Schwartz (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12992310#comment-12992310 ] 

Andy Schwartz commented on MYFACES-3033:
----------------------------------------

Trinidad also suppress table iteration based on the phase id.  From UIXComponent:

      // determine whether this visit should be iterating.  If it shouldn't, don't
      // even call the protected hook.  We currently don't iterate during the
      // restore view phase when we are visiting all of the components.
      boolean noIterate = (visitContext.getIdsToVisit() == VisitContext.ALL_IDS) &&
                          (context.getCurrentPhaseId() == PhaseId.RESTORE_VIEW);

      doneVisiting =  (noIterate)
                        ? uixParentComponent._visitAllChildren(visitContext, callback)
                        : uixParentComponent.visitChildren(visitContext, callback);

However, as of the following MyFaces fix:

MYFACES-3036 Support SKIP_ITERATION FacesContext property
https://issues.apache.org/jira/browse/MYFACES-3036

Both MyFaces and Mojarra support the "javax.faces.visit.SKIP_ITERATION" FacesContext property in their 2.0.x code bases.  This means that iterating components can now decide whether or not to iterate based on the presence of this property.

I have logged the following issue against Trinidad on this topic:

TRINIDAD-2030 Honor SKIP_ITERATION FacesContext property
https://issues.apache.org/jira/browse/TRINIDAD-2030

It would be good if RichFaces would also take advantage of this.  This should avoid the problem reported here - ie. if iterating components check for the SKIP_ITERATION property rather checking for restore view phase, the DebugPhaseListener's tree visit should be able to safely evaluate EL.




> Improve DebugPhaseListener for UIData and SKIP_ITERATION
> --------------------------------------------------------
>
>                 Key: MYFACES-3033
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3033
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: General
>    Affects Versions: 2.1.0
>            Reporter: Martin Kočí
>
> <h:dataTable var="row" >
>   <h:column>
>     <h:outputText rendered="#{bean.isRendered(row)}"
> There is new VisitHint.SKIP_ITERATION in JSF 2.1. If that hint is used UIData iterate over children in "flat" manner and therefore no row is available - bean.isRendered(row) obtains null as parameter and NPE can happen. One problem in this situation is a component tree walk before RESTORE_VIEW from DebugPhaseListener:
> java.lang.NullPointerException
> foo.bazz.bean.isRendered
> ...
> at org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:85)
> at javax.faces.component._DeltaStateHelper.eval(_DeltaStateHelper.java:260)
> at javax.faces.component.UIComponentBase.isRendered
> ...
> at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:991)
> at org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener._doTreeVisit(DebugPhaseListener.java:310)
> at org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener.afterPhase(DebugPhaseListener.java:286)

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira