Skip to content

Commit

Permalink
MYFACES-3556 [perf] call markInitialState() inside vdl.retargetAttach…
Browse files Browse the repository at this point in the history
…edObjects() and vdl.retargetMethodExpressions()
  • Loading branch information
Leonardo Uribe committed May 31, 2012
1 parent 98b55d5 commit c71a76b
Showing 1 changed file with 63 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@
import org.apache.myfaces.view.facelets.util.ReflectionUtil;

import org.apache.myfaces.view.facelets.impl.SectionUniqueIdCounter;
import org.apache.myfaces.view.facelets.tag.jsf.PartialMethodExpressionActionListener;
import org.apache.myfaces.view.facelets.tag.jsf.PartialMethodExpressionValidator;
import org.apache.myfaces.view.facelets.tag.jsf.PartialMethodExpressionValueChangeListener;

/**
* This class represents the abstraction of Facelets as a ViewDeclarationLanguage.
Expand Down Expand Up @@ -806,6 +809,10 @@ public void retargetAttachedObjects(FacesContext context,
{
currentHandler.applyAttachedObject(context, component);
}
if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
{
component.markInitialState();
}
}
}
else if ((currentTarget instanceof BehaviorHolderAttachedObjectTarget &&
Expand Down Expand Up @@ -860,6 +867,10 @@ else if ((currentTarget instanceof BehaviorHolderAttachedObjectTarget &&
currentHandler.applyAttachedObject(context, component);
}
}
if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
{
component.markInitialState();
}
}
}
}
Expand Down Expand Up @@ -1096,6 +1107,10 @@ else if ("valueChangeListener".equals(attributeName))
mctx.clearMethodExpressionAttribute(innerComponent, attributeName);

retargetMethodExpressions(context, innerComponent);
if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
{
innerComponent.markInitialState();
}
}
else
{
Expand All @@ -1115,6 +1130,10 @@ else if ("valueChangeListener".equals(attributeName))
{
((ActionSource2)innerComponent).setActionExpression(methodExpression);
}
if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
{
innerComponent.markInitialState();
}
}
else if ("actionListener".equals(attributeName))
{
Expand Down Expand Up @@ -1142,10 +1161,21 @@ else if ("actionListener".equals(attributeName))
createMethodExpression(elContext,
attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY), attributeNameValueExpression);

actionListener = new MethodExpressionActionListener(methodExpression, methodExpression2);
if (mctx.isUsingPSSOnThisView())
{
actionListener = new PartialMethodExpressionActionListener(methodExpression, methodExpression2);
}
else
{
actionListener = new MethodExpressionActionListener(methodExpression, methodExpression2);
}
}
((ActionSource2) innerComponent).addActionListener(actionListener);
mctx.addMethodExpressionTargeted(innerComponent, attributeName, actionListener);
if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
{
innerComponent.markInitialState();
}
}
else if ("validator".equals(attributeName))
{
Expand All @@ -1169,11 +1199,21 @@ else if ("validator".equals(attributeName))
createMethodExpression(elContext,
attributeExpressionString, Void.TYPE,
VALIDATOR_SIGNATURE), attributeNameValueExpression);

validator = new MethodExpressionValidator(methodExpression);
if (mctx.isUsingPSSOnThisView())
{
validator = new PartialMethodExpressionValidator(methodExpression);
}
else
{
validator = new MethodExpressionValidator(methodExpression);
}
}
((EditableValueHolder) innerComponent).addValidator(validator);
mctx.addMethodExpressionTargeted(innerComponent, attributeName, validator);
if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
{
innerComponent.markInitialState();
}
}
else if ("valueChangeListener".equals(attributeName))
{
Expand Down Expand Up @@ -1202,10 +1242,21 @@ else if ("valueChangeListener".equals(attributeName))
attributeExpressionString, Void.TYPE,
EMPTY_CLASS_ARRAY), attributeNameValueExpression);

valueChangeListener = new MethodExpressionValueChangeListener(methodExpression, methodExpression2);
if (mctx.isUsingPSSOnThisView())
{
valueChangeListener = new PartialMethodExpressionValueChangeListener(methodExpression, methodExpression2);
}
else
{
valueChangeListener = new MethodExpressionValueChangeListener(methodExpression, methodExpression2);
}
}
((EditableValueHolder) innerComponent).addValueChangeListener(valueChangeListener);
mctx.addMethodExpressionTargeted(innerComponent, attributeName, valueChangeListener);
if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
{
innerComponent.markInitialState();
}
}
}
}
Expand Down Expand Up @@ -1246,6 +1297,10 @@ attributeExpressionString, _getReturnType(methodSignature),
mctx.clearMethodExpressionAttribute(innerComponent, attributeName);

retargetMethodExpressions(context, innerComponent);
if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
{
innerComponent.markInitialState();
}
}
else
{
Expand All @@ -1260,6 +1315,10 @@ attributeExpressionString, _getReturnType(methodSignature),
{
innerComponent.getAttributes().put(attributeName, methodExpression);
}
if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
{
innerComponent.markInitialState();
}
}
}
//Store the method expression to the topLevelComponent to allow reference it through EL
Expand Down

0 comments on commit c71a76b

Please sign in to comment.