Re: Issues using View Pooling - ViewScope is missing for static structure views?

2015-03-25 Thread Leonardo Uribe
Hi

I was able to reproduce the problem. Thanks for the log, it helped a
lot to understand what's going on. It looks like the call to
restoreState was overriding view scope, so the fix done was add some
lines to check that case and avoid it. I added some junit tests and on
the way I fixed a small issue with view root metadata facet.

I hope these fixes will solve your problem. Let us know if that is the
case or not.

regards,

Leonardo Uribe

2015-03-24 16:39 GMT-05:00 Chris Kulinski chriskulin...@yahoo.com:
 Leonardo - Thanks for the research and updated cases on the patch. We'll
 apply your recent changes to our testing and try again.

 Unfortunately, the additional fixes for this defect didn't fix our other
 defect with missing View Scope.  I'll create a new issue in the issue
 tracker to watch this. We'll work on assembling a simple demo that shows the
 problem.

 The issue might happen because the View Pooling code doesn't always run
 during RESTORE_VIEW phase.  It only seems to run in RESTORE_VIEW for AJAX
 post-backs.  Any changes to our ViewScope objects that happen before
 RENDER_RESPONSE are lost because it looks like the ViewScope is sometimes
 reattached at RENDER_RESPONSE.

 We've added manual debugging to the MyFaces source to attempt to show the
 problem.   Does this help enough to troubleshoot what's happening?

 On the very first request to the view after application startup, the
 behavior is correct. I guess this is because the View hasn't been flushed
 and remapped by the pool yet.  There is a second instance of the Bean
 created, but that's maybe after the view is rendered (in saveViewRootState,
 storeStatic and pushStaticStructureView).

 2015-03-24 16:48:23,235 DEBUG
 [com.autotrader.enterprise.common.context.LogPhaseListener] (default task-1)
 Start Phase RESTORE_VIEW(1)
 2015-03-24 16:48:23,374 DEBUG
 [com.autotrader.enterprise.common.context.LogPhaseListener] (default task-1)
 End Phase RESTORE_VIEW(1)
 2015-03-24 16:48:23,400 INFO  [stdout] (default task-1)
 HelloCdiTwoScopedBean - constructed new instance
 2015-03-24 16:48:23,406 DEBUG
 [com.autotrader.enterprise.common.context.LogPhaseListener] (default task-1)
 Start Phase RENDER_RESPONSE(6)
 2015-03-24 16:48:23,420 INFO  [stdout] (default task-1) POOLING:
 retrieveStaticStructureMetadata root:/examples/ajaxsamples/helloAjax.xhtml
 key:org.apache.myfaces.view.facelets.pool.impl.MetadataViewKeyImpl@f7711892
 2015-03-24 16:48:23,420 INFO  [stdout] (default task-1) POOLING:
 retrieveStaticStructureMetadata metadatanull
 2015-03-24 16:48:23,505 INFO  [stdout] (default task-1) POOLING
 root:/examples/ajaxsamples/helloAjax.xhtml dynamic:false
 2015-03-24 16:48:23,505 INFO  [stdout] (default task-1) POOLING:
 saveViewRootState root:/examples/ajaxsamples/helloAjax.xhtml
 2015-03-24 16:48:23,506 INFO  [stdout] (default task-1) POOLING: storeStatic
 root:/examples/ajaxsamples/helloAjax.xhtml
 keyorg.apache.myfaces.view.facelets.pool.impl.MetadataViewKeyImpl@f7711892
 2015-03-24 16:48:23,551 INFO  [stdout] (default task-1)
 HelloCdiTwoViewScopedBean - constructed new instance
 2015-03-24 16:48:23,681 INFO  [stdout] (default task-1) POOLING:
 pushStaticStructureView
 key:org.apache.myfaces.view.facelets.pool.impl.MetadataViewKeyImpl@f7711892
 entry:org.apache.myfaces.view.facelets.pool.impl.SoftViewEntry@27ed7f
 2015-03-24 16:48:23,683 DEBUG
 [com.autotrader.enterprise.common.context.LogPhaseListener] (default task-1)
 End Phase RENDER_RESPONSE(6)

 On the next request, Pooling isn't executed until during RENDER_RESPONSE.
 This bean is created after RESTORE_VIEW, but before RENDER_RESPONSE (via
 PrettyFaces).  The view is using a 2nd instance of the Bean for rendering,
 without the values from the initial instance (after popStaticStructureView).

 2015-03-24 17:18:51,090 DEBUG
 [com.autotrader.enterprise.common.context.LogPhaseListener] (default task-6)
 Start Phase RESTORE_VIEW(1)
 2015-03-24 17:18:51,091 DEBUG
 [com.autotrader.enterprise.common.context.LogPhaseListener] (default task-6)
 End Phase RESTORE_VIEW(1)
 2015-03-24 17:18:51,093 INFO  [stdout] (default task-6)
 HelloCdiTwoScopedBean - constructed new instance
 2015-03-24 17:18:51,094 DEBUG
 [com.autotrader.enterprise.common.context.LogPhaseListener] (default task-6)
 Start Phase RENDER_RESPONSE(6)
 2015-03-24 17:18:51,094 INFO  [stdout] (default task-6) POOLING:
 retrieveStaticStructureMetadata root:/examples/ajaxsamples/helloAjax.xhtml
 key:org.apache.myfaces.view.facelets.pool.impl.MetadataViewKeyImpl@f7711892
 2015-03-24 17:18:51,094 INFO  [stdout] (default task-6) POOLING:
 retrieveStaticStructureMetadata
 metadataorg.apache.myfaces.view.facelets.pool.impl.ViewStructureMetadataImpl@15744d1
 2015-03-24 17:18:51,094 INFO  [stdout] (default task-6) POOLING:
 popStaticStructureView
 key:org.apache.myfaces.view.facelets.pool.impl.MetadataViewKeyImpl@f7711892
 q:org.apache.myfaces.view.facelets.pool.impl.ViewPoolEntryHolder@672a58
 2015-03-24 17:18:51,098 INFO  [stdout] (default 

EL 3.0 Static Field References

2015-03-25 Thread William Lucy


Hi All,

I'm running into some issues trying to test the EL 3.0 functionality on
MyFaces 2.2.7 + Tomcat 8.0.16.  My understanding is that we should be able
to reference static fields/methods directly from facelets, eg.

  Boolean.TRUE test: [h:outputText id=out2
  value=#{Boolean.TRUE}/]

should return Boolean.TRUE test: [true].  This isn't the case, however;
no value is returned, and nothing's logged.  Additionally, when I try to
access a static field on a local ManagedBean, I get

  ...
  javax.el.PropertyNotFoundException: Property 'staticReference' not
  found on type beans.EL30StaticFieldsAndMethodsBean
 at javax.el.BeanELResolver$BeanProperties.get
 (BeanELResolver.java:244)
 at javax.el.BeanELResolver$BeanProperties.access$300
 (BeanELResolver.java:221)
 at javax.el.BeanELResolver.property(BeanELResolver.java:331)
 at javax.el.BeanELResolver.getValue(BeanELResolver.java:95)
 at javax.el.CompositeELResolver.getValue
 (CompositeELResolver.java:66)
 at
 
org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue
(FacesCompositeELResolver.java:179)
 ... 1 more

Where the ManagedBean is defined simply as

  package beans;
  import javax.faces.bean.ApplicationScoped;
  import javax.faces.bean.ManagedBean;

  @ManagedBean(name = staticbean)
  @ApplicationScoped
  public class EL30StaticFieldsAndMethodsBean {
 ...
  public static final String staticReference = static reference;
 ...
  }

Has anyone else tried working with these kinds of EL 3.0 features?  Or am I
possibly just missing something here?

Thanks,
Bill Lucy

Re: EL 3.0 Static Field References

2015-03-25 Thread Leonardo Uribe
Hi

It is in the spec, it should work.

There is some code in
org.apache.myfaces.el.unified.ResolverBuilderForFaces that deals with
this:

if (STATIC_FIELD_EL_RESOLVER_CLASS != null 
GET_STREAM_EL_RESOLVER_METHOD != null)
{
try
{
ELResolver streamElResolver = (ELResolver)
GET_STREAM_EL_RESOLVER_METHOD.invoke(
getRuntimeConfig().getExpressionFactory());
if (streamElResolver != null)
{
// By default return null, but in a EL 3
implementation it should be there,
// this is just to avoid exceptions in junit testing
list.add(streamElResolver);
}
list.add((ELResolver)
STATIC_FIELD_EL_RESOLVER_CLASS.newInstance());
}

The code checks for javax.el.StaticFieldELResolver class and
ExpressionFactory.getStreamELResolver(...) method before
add both EL resolvers.

If MyFaces jars cannot locate these classes, the EL resolvers
are not loaded (because it assumes EL  3.0), and the
described behavior will happen.

regards,

Leonardo Uribe

2015-03-25 15:14 GMT-05:00 William Lucy wtl...@us.ibm.com:


 Hi All,

 I'm running into some issues trying to test the EL 3.0 functionality on
 MyFaces 2.2.7 + Tomcat 8.0.16.  My understanding is that we should be able
 to reference static fields/methods directly from facelets, eg.

   Boolean.TRUE test: [h:outputText id=out2
   value=#{Boolean.TRUE}/]

 should return Boolean.TRUE test: [true].  This isn't the case, however;
 no value is returned, and nothing's logged.  Additionally, when I try to
 access a static field on a local ManagedBean, I get

   ...
   javax.el.PropertyNotFoundException: Property 'staticReference' not
   found on type beans.EL30StaticFieldsAndMethodsBean
  at javax.el.BeanELResolver$BeanProperties.get
  (BeanELResolver.java:244)
  at javax.el.BeanELResolver$BeanProperties.access$300
  (BeanELResolver.java:221)
  at javax.el.BeanELResolver.property(BeanELResolver.java:331)
  at javax.el.BeanELResolver.getValue(BeanELResolver.java:95)
  at javax.el.CompositeELResolver.getValue
  (CompositeELResolver.java:66)
  at
  
 org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue
 (FacesCompositeELResolver.java:179)
  ... 1 more

 Where the ManagedBean is defined simply as

   package beans;
   import javax.faces.bean.ApplicationScoped;
   import javax.faces.bean.ManagedBean;

   @ManagedBean(name = staticbean)
   @ApplicationScoped
   public class EL30StaticFieldsAndMethodsBean {
  ...
   public static final String staticReference = static reference;
  ...
   }

 Has anyone else tried working with these kinds of EL 3.0 features?  Or am I
 possibly just missing something here?

 Thanks,
 Bill Lucy