use of org.apache.myfaces.view.facelets.el.FaceletStateValueExpression in project myfaces by apache.
the class ForEachHandler method setVar.
private void setVar(FaceletContext ctx, UIComponent parent, String uniqueId, String base, String v, ValueExpression ve, ValueExpression srcVE) {
AbstractFaceletContext actx = ((AbstractFaceletContext) ctx);
PageContext pctx = actx.getPageContext();
if (srcVE != null) {
FaceletState faceletState = ComponentSupport.getFaceletState(ctx, parent, true);
faceletState.putBinding(uniqueId, base, ve);
// Put the indirect EL into context
ValueExpression fve = new FaceletStateValueExpression(uniqueId, base);
pctx.getAttributes().put(v, fve);
} else {
pctx.getAttributes().put(v, ve);
}
}
use of org.apache.myfaces.view.facelets.el.FaceletStateValueExpression in project myfaces by apache.
the class UserTagHandler method apply.
/**
* Iterate over all TagAttributes and set them on the FaceletContext's VariableMapper, then include the target
* Facelet. Finally, replace the old VariableMapper.
*
* @see TagAttribute#getValueExpression(FaceletContext, Class)
* @see jakarta.el.VariableMapper
* @see jakarta.faces.view.facelets.FaceletHandler#apply(jakarta.faces.view.facelets.FaceletContext,
* jakarta.faces.component.UIComponent)
*/
@Override
public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException, ELException {
AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
// eval include
try {
String[] names = null;
ValueExpression[] values = null;
if (this._vars.length > 0) {
names = new String[_vars.length];
values = new ValueExpression[_vars.length];
for (int i = 0; i < _vars.length; i++) {
names[i] = _vars[i].getLocalName();
values[i] = _vars[i].getValueExpression(ctx, Object.class);
}
}
actx.pushTemplateContext(new TemplateContextImpl());
actx.pushClient(this);
FaceletCompositionContext fcc = FaceletCompositionContext.getCurrentInstance(ctx);
String uniqueId = fcc.startComponentUniqueIdSection();
try {
if (this._vars.length > 0) {
if (ELExpressionCacheMode.alwaysRecompile.equals(actx.getELExpressionCacheMode())) {
FaceletState faceletState = ComponentSupport.getFaceletState(ctx, parent, true);
for (int i = 0; i < this._vars.length; i++) {
faceletState.putBinding(uniqueId, names[i], values[i]);
ValueExpression ve = new FaceletStateValueExpression(uniqueId, names[i]);
actx.getTemplateContext().setParameter(names[i], ve);
}
} else {
for (int i = 0; i < this._vars.length; i++) {
((AbstractFaceletContext) ctx).getTemplateContext().setParameter(names[i], values[i]);
}
}
}
// The only mode that can support EL caching in this condition is alwaysRedirect.
if (!ELExpressionCacheMode.alwaysRecompile.equals(actx.getELExpressionCacheMode())) {
actx.getTemplateContext().setAllowCacheELExpressions(false);
}
ctx.includeFacelet(parent, this._location);
} finally {
fcc.endComponentUniqueIdSection();
}
} catch (FileNotFoundException e) {
throw new TagException(this.tag, e.getMessage());
} finally {
// make sure we undo our changes
actx.popClient(this);
actx.popTemplateContext();
}
}
use of org.apache.myfaces.view.facelets.el.FaceletStateValueExpression in project myfaces by apache.
the class ParamHandler method apply.
public void apply(FaceletContext ctx, UIComponent parent, String nameStr, ValueExpression valueVE, String uniqueId) throws IOException, FacesException, FaceletException, ELException {
AbstractFaceletContext actx = ((AbstractFaceletContext) ctx);
if (ELExpressionCacheMode.alwaysRecompile.equals(actx.getELExpressionCacheMode())) {
FaceletState faceletState = ComponentSupport.getFaceletState(ctx, parent, true);
faceletState.putBinding(uniqueId, nameStr, valueVE);
ValueExpression ve = new FaceletStateValueExpression(uniqueId, nameStr);
actx.getTemplateContext().setParameter(nameStr, ve);
} else {
actx.getTemplateContext().setParameter(nameStr, valueVE);
}
if (actx.getTemplateContext().isAllowCacheELExpressions()) {
if (ELExpressionCacheMode.strict.equals(actx.getELExpressionCacheMode()) || ELExpressionCacheMode.allowCset.equals(actx.getELExpressionCacheMode())) {
actx.getTemplateContext().setAllowCacheELExpressions(false);
}
}
}
Aggregations