cancel
Showing results for 
Search instead for 
Did you mean: 

Evaluators

jlbarrera
Champ in-the-making
Champ in-the-making
Hi !

I want verifity (in browse.jsp) that an item has translatable aspect, i think that create a new booleanEvaluator is the way. How i can create this?

thanks!
5 REPLIES 5

gavinc
Champ in-the-making
Champ in-the-making
The following should work:


<a:booleanEvaluator value='#{NavigationBean.currentNode.aspects["translatable"] != null}'>
   <some-component/>
</a:booleanEvaluator>

jlbarrera
Champ in-the-making
Champ in-the-making
this is the error:
———————-

javax.faces.FacesException: /jsp/browse/browse.jsp(481,52) se esperaba s?mbolo igual

caused by:
org.apache.jasper.JasperException: /jsp/browse/browse.jsp(481,52) se esperaba s?mbolo igual

caused by:
org.apache.jasper.JasperException: /jsp/browse/browse.jsp(481,52) se esperaba s?mbolo igual

And this is the code from browse.jsp:
——————————————————

<a:booleanEvaluator value="#{r.aspects["translatable"] != null}">
<a:actionLink value="#{msg.espanol}" image="/images/icons/flag-es.gif" showLink="false" styleClass="inlineAction" />     
</a:booleanEvaluator>

Where "r" is:
——————

<a:richList id="contentRichList" binding="#{BrowseBean.contentRichList}" viewMode="#{BrowseBean.browseViewMode}" pageSize="#{BrowseBean.browsePageSize}"
styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%"
value="#{BrowseBean.content}" var="r">

This is correct? Where is the error?

Thanks!

jlbarrera
Champ in-the-making
Champ in-the-making
I try with:

<a:booleanEvaluator value="#{r.aspects == null}">
<a:actionLink value="#{msg.espanol}" image="/images/icons/flag-es.gif" showLink="false" styleClass="inlineAction" />     
</a:booleanEvaluator>

This booleanEvaluator return TRUE, but the item has aspect! :?:

kevinr
Star Contributor
Star Contributor
I know what the problem is here. The code Gavin posted will work for an action outside of a RichList component. The code you are trying is inside a RichList component so the current node context object "#{r}" is a special kind of Node. It's really a sub-class of Node called MapNode. This object exposes itself using the Java Map interace, which means that the JSF expression language will assume all access to the object is treated as MapNode.get("…") - which means that you cannot access the normal methods such as Node.getAspect().

The reason for this is that there are various additional pseudo generated properties added to the MapNode so that the RichList component can display additional information - such as "size" or "url".

If you wish to have acces to the aspects for a MapNode then you need to add a pseudo property for it. Look for this method in BrowseBean:


public void setupCommonBindingProperties(Node node)

and add this line to the method:

   node.addPropertyResolver("aspects", this.resolverAspects);

and now add this anonymous inner class below the method to resolve the pseudo property:

   public NodePropertyResolver resolverAspects= new NodePropertyResolver() {
      public Object get(Node node) {
         return node.getAspects();
      }
   };

Then your JSP code should work.

Hope this helps!

Kevin

jlbarrera
Champ in-the-making
Champ in-the-making
OK Thanks. Now all work fine!  Smiley Happy