cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying Constrainted Meta-data in the search results page

astocks
Champ in-the-making
Champ in-the-making
Hi,

I've been modifying the columns of my search results page. Works fine for most of my custom meta-data but not for any meta-data which has constraints on it (so they get chosen via a drop-down box).

The error it gives is:
javax.faces.FacesException: java.lang.String
caused by:
org.apache.jasper.JasperException: java.lang.String
caused by:
java.lang.ClassCastException: java.lang.String

Does this mean I have to use a specific renderer or something?

Anyone done this before or have any idea?
9 REPLIES 9

gavinc
Champ in-the-making
Champ in-the-making
When setting the value for a drop down box you need to pass a List of SelectItem objects, it may be that you are passing a String as the value for the drop down box.

astocks
Champ in-the-making
Champ in-the-making
Thanks Gavin - I'll try that!

astocks
Champ in-the-making
Champ in-the-making
Actually Gavin, I think you misunderstood me. I actually want to display only the actual chosen value, for example in the search results page.

It works for non constrainted meta-data, but not for any metadata with constraints.

gavinc
Champ in-the-making
Champ in-the-making
Ahh OK, is the property defined as a multiple valued property?

If so, the object you get back from the repository is a List, which may also explain the ClassCastException.

astocks
Champ in-the-making
Champ in-the-making
Thanks for the help Gavin, been a bit busy so haven't had much chance to work on this.

You say that the multiple valued property is returned as a list, so how are normal properties returned? And how does this affect how the declaration of a property in the results page is made?

Do I have to implement something like below in order for this to work?

<show-property name="mimetype" display-label-id="mimetype" converter="org.alfresco.faces.MimeTypeConverter" showInEditMode="false" />

Do you have any idea what would have to be changed to be able to display the value of a "drop-down" piece of metadata in the search results page? Any pointers would be appreciated.

gavinc
Champ in-the-making
Champ in-the-making
Properties are returned using the appropriate type i.e. d:text will return a Java String object. If the property is marked as multi valued then a List of String objects is returned.

You will most likely need to create a converter to apply to the component you are using in the search results. It's difficult to tell without seeing what you've done, if you could post the changes you've made that may help i.e. the JSP and the custom model you are using.

astocks
Champ in-the-making
Champ in-the-making
Thanks for the quick reply,

Here are my changes, hopefully it helps:

Custom Data Model:

   <constraints>
   <constraint name="dmSmiley Frustratedervice_Line_List" type="LIST">
      <parameter name="allowedValues">
         <list>
            <value></value>
            <value>Strategy</value>
            <value>Operations</value>
            <value>Human Capital</value>
            <value>Enterprise Applications</value>
            <value>Technology Integration</value>
         </list>
      </parameter>
   </constraint>
</constraints> 


and within the type definition:

<property name="dmSmiley Frustratedervice_Line" >
        <type>d:text</type>
        <constraints>
                  <constraint ref="dmSmiley Frustratedervice_Line_List"/>
        </constraints>
</property>

In the web-client-config-custom.xml:

<config evaluator="node-type" condition="content">
<property-sheet>
<show-property name="dmSmiley Frustratedervice_Line" show-in-view-mode="true" display-label="Service Line"
ignore-if-missing="false"/>
</property-sheet>
</config>


Browse JSP:

<a:column id="col19" style="text-align:left" rendered="#{BrowseBean.browseViewMode == 'details' || BrowseBean.browseViewMode == 'icons'}}">
<f:facet name="header">
<a:sortLink id="col19-sort" label="Service Line" value="modified" styleClass="header"/>
</f:facet>
<hSmiley SurprisedutputText id="col19-txt" value="#{r['dmSmiley Frustratedervice_Line']}">
</hSmiley SurprisedutputText>
</a:column>


I have made the same changes for parameters which do not have any constraints and they work. However for this (and other similar ones) I get a "String" type error.

gavinc
Champ in-the-making
Champ in-the-making
I tried this out on my system and this has nothing whatsoever to do with the value inside the property, it's actually the value binding expression in the rendered property that is the problem.

rendered="#{BrowseBean.browseViewMode == 'details' || BrowseBean.browseViewMode == 'icons'}}"

has an extra } character at the end. This was therefore evaluting to "true}" or "false}" which would not convert to a Boolean object to check whether the column should be rendered or not.

Remove the extra } and it should work, it did for me!

astocks
Champ in-the-making
Champ in-the-making
Gavin, thank you very much…

Haven't tried it yet but I copied an pasted that code so I guess it will work.

Sorry for wasting your time but I think I have been looking at it for so long I would never have spotted that!