cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Action Evaluator

mangar
Star Contributor
Star Contributor
I am having a problem with a custom evaluator.  I have an action in my share-config-custom.xml:

      <action id="sammy.actions.writeToLog"
              icon="log_write"
              type="javascript"
              label="actions.sammy.writeToLog">
         <param name="function">onActionSimpleRepoAction</param>
         <param name="successMessage">message.writeToLog.success</param>
         <param name="failureMessage">message.WriteToLog.failure</param>
         <evaluator negate="true">sammy.writeToLog.Evaluator</evaluator>
      </action>

in my custom-slingshot-application-context.xml I have a simple one liner bean declaration:
<bean id="sammy.writeToLog.Evaluator" class="com.sammy.share.action.evaluator.LogWriteEvaluator">
</bean>

and in my jar file located in share/WEB-INF/lib I have this:
public class LogWriteEvaluator extends BaseEvaluator {

    @Override
   public boolean evaluate(JSONObject jsonObject) {
          return true;
   }
   
}


if I comment out the evaluator in the action declaration, It shows up fine, so I know that works.

what am I missing?
6 REPLIES 6

mtielemans
Champ in-the-making
Champ in-the-making
The evaluator always returns true. However, in your use of the evaluator you negate the output by using the attribute
negate="true"
. This means that the output of the evaluator is inverted. Therefore, true = false and the action doesn't show.

If you make the evaluator return false, or leave out the negate attribute or set it to false, the action should show up.

Hi,

  I have also tried for making a custom evaluator so that it should restrict the articular action in share for nly some folders. I have explained the error in the below text file.

Please help me with this.

Thanks in advance.

jpotts
World-Class Innovator
World-Class Innovator
Try moving your JAR to $TOMCAT_HOME/webapps/share/WEB-INF/lib instead of using $TOMCAT_HOME/shared/lib.

Jeff

mrinal3199
Champ in-the-making
Champ in-the-making
Thanks for your time jpotts!! But my jar is there only in tomcat\webapps\share\WEB-INF\lib… and i have all the required jars in buildpath of eclipse and those are present here also in the same path…I dn't understand where i went wrong.

Thanks in advance.

mani
Champ in-the-making
Champ in-the-making
From my understanding the evaluator class you created is not there in your JAR, make sure your build was successful and contains this class.

mrinal3199
Champ in-the-making
Champ in-the-making
Hi mani,

   Thanks for your reply. That is what i am not understanding. Actually i have this java class in share jar in package as "org.alfresco.web.evaluator.doclib.action". And i have build this jar and placed it in "C:\tmcat\Webaps\share\WEB-INF\lib". I don't know where i am wrong.

Thanks in advance,