1 Reply Latest reply on Aug 31, 2009 5:26 AM by nbelaevski

    Access Properties with custom Component in a4j:repeat



      following Code-Fragment in a JSP let me despair.

      <a4j:repeat value="#{workspace.data.selectedMiddleLevelPanel.actions}" var="action" rowKeyVar="index">
       <me:checkPermission permission="#{action.permission}" toolTip="#{system.completeCmsUrl}">

      The UIComponentELTag for me:checkPermission tries to resolve the ValueExpression permission and toolTip.
      The Property toolTip is for debugging and the Taghandler resolves the ValueExpression for toolTip correctly. But the TagHandler can't resolve the Expression in the Property permission.
      Here the Code for the TagHandler:
      package de.meine_energie.web.taglib.permission;
      import javax.el.ValueExpression;
      import javax.faces.component.UIComponent;
      import javax.faces.webapp.UIComponentELTag;
      import javax.servlet.jsp.JspException;
      import de.meine_energie.permission.Permission;
      public class CheckPermissionTag extends UIComponentELTag {
       private ValueExpression permission = null;
       private ValueExpression toolTip = null;
       public String getComponentType() {
       return "de.meine_energie.web.taglib.permission.CheckPermissionComponent";
       public String getRendererType() {
       return null;
       protected void setProperties(UIComponent component) {
       CheckPermissionComponent permComp = (CheckPermissionComponent)component;
       Permission p = (Permission)permission.getValue(getELContext());
       if(p != null){
       System.out.println("permission is not null"+p.getAction());
       } else {
       System.out.println("permission is null");
       if(toolTip != null){
       String tool = (String)toolTip.getValue(getELContext());
       System.out.println("Tooltip: "+tool);
       System.out.println("valueExpression: "+toolTip.getExpressionString());
       } else {
       System.out.println("Tooltip is nulL!!");
       public int doStartTag() throws JspException {
       return super.doStartTag();
       public void setPermission(ValueExpression permission) {
       this.permission = permission;
       public ValueExpression getPermission() {
       return permission;
       public int doEndTag() throws JspException {
       return super.doEndTag();
       public void release() {
       permission = null;
       toolTip = null;
       public void setToolTip(ValueExpression toolTip) {
       this.toolTip = toolTip;
       public ValueExpression getToolTip() {
       return toolTip;

      Why can't i access the Property in the loop? Is there another way to resolve ValueExpressions?
      Can anybody help me please?

      ... thanks!

        • 1. Re: Access Properties with custom Component in a4j:repeat


          That't because you're trying to evaluate this property in component tree build time, however a4j:repeat as another JSF iteration component makes it available on render-time. The right solution is not to evaluate these properties, but add them to VariableMapper - see Facelets source codes - all templating features are built around that.