cancel
Showing results for 
Search instead for 
Did you mean: 

Cryptic 'Unable to find setter method for attribute&quo

steel
Champ in-the-making
Champ in-the-making
I have created a new HasAspectEvaluator custom tag.

<tag>
        <name>hasAspectEvaluator</name>
        <tag-class>com.tsgrp.alfresco.web.ui.common.tag.evaluator.HasAspectEvaluatorTag</tag-class>
        <body-content>JSP</body-content>

        <attribute>
            <name>id</name>
            <required>false</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>

        <attribute>
            <name>value</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>

        <attribute>
            <name>binding</name>
            <required>false</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>

        <attribute>
            <name>condition</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
    </tag>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I have the setters correctly set.
public class HasAspectEvaluator extends BaseEvaluator
{
     /**
     * the string condition to match value against
     */
    private String condition = null;

    /**
     * Evaluate against the component attributes. Return true to allow the inner
     * components to render, false to hide them during rendering.
     *
     * @return true to allow rendering of child components, false otherwise
     */
    public boolean evaluate()
    {
        FacesContext context = FacesContext.getCurrentInstance();
        NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();

        boolean result = false;

        try
        {
            result = nodeService.hasAspect((NodeRef)getValue(), Repository.resolveToQName(getCondition()));
        }
        catch (Exception err)
        {
            // return default value on error
            s_logger.debug("HasAspectEvaluator error : " + getValue());
        }

        return result;
    }

    /**
     * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object)
     */
    public void restoreState(FacesContext context, Object state)
    {
        Object values[] = (Object[]) state;
        // standard component attributes are restored by the super class
        super.restoreState(context, values[0]);
        this.condition = (String) values[1];
    }

    /**
     * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
     */
    public Object saveState(FacesContext context)
    {
        Object values[] = new Object[2];
        // standard component attributes are saved by the super class
        values[0] = super.saveState(context);
        values[1] = this.condition;
        return (values);
    }

    public String getCondition()
    {
        ValueBinding vb = getValueBinding("condition");
        if (vb != null)
        {
            this.condition = (String) vb.getValue(getFacesContext());
        }

        return this.condition;
    }

    public void setCondition(String condition)
    {
        this.condition = condition;
    }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I also have the component correctly defined in the xml. Yet when I try to load the JSP page:

17:04:39,536 ERROR [[localhost].[/connectsite].[jsp]] Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /jsp/browse/browse.jsp(675,4) Unable to find setter method for attribute: condition
   at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
   at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
   at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
   at org.apache.jasper.compiler.Generator$GenerateVisitor.evaluateAttribute(Generator.java:2709)
   at org.apache.jasper.compiler.Generator$GenerateVisitor.generateSetters(Generator.java:2857)
   at org.apache.jasper.compiler.Generator$GenerateVisitor.generateCustomStart(Generator.java:2176)
   at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1685)‍‍‍‍‍‍‍‍‍

Here's the JSP code:

<t:hasAspectEvaluator value="#{r}" condition="tsg:faxDoc">
        <r:permissionEvaluator value="#{r}" allow="ChangePermissions">
            <a:actionLink value="#{msg.manage_content_users}" image="/images/icons/invite.gif"
                          action="dialog:manageContentUsers" actionListener="#{BrowseBean.setupContentAction}">
                <f:param name="id" value="#{r.id}"/>
            </a:actionLink>
        </r:permissionEvaluator>
    </t:hasAspectEvaluator>‍‍‍‍‍‍‍‍

I am really stumped on this. I have tried re-compiling, re-deploying, re-starting my IDE, tried Tomcat 5.5.15 & 5.5.16. All produce the same errors. I have gone over my code over and over again.

Any ideas?

thanks.
3 REPLIES 3

kevinr
Star Contributor
Star Contributor
Can you show the code for your HasAspectEvaluatorTag class? As this is the class that the "unable to find…" error is related too - there should be a setter method for "condition" in that class i.e. setCondition(String s)

Thanks,

Kevin

gavinc
Champ in-the-making
Champ in-the-making
Hi,

The error is coming from the tag class not the evaluator implementation that you have listed.

Basically, setCondition() is missing from com.tsgrp.alfresco.web.ui.common.tag.evaluator.HasAspectEvaluatorTag.

steel
Champ in-the-making
Champ in-the-making
Yes that was the problem.  Thanks a lot for the help!