Skip to Content
author's profile photo Former Member
Former Member

Problem with resource filter on metadata properties

Hi Everybody,

I've developed a resource filter as described in the following url

https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2102

Instead of an input field for the searchvalue, I created a dropdownlistbox containing all the allowed values of a specific metadata property in KM.

the user is now able to select the filtervalue and click the "Filter button". But when this button is clicked, the resources are not being filtered at all.

this is my code for the ResourceFilter:

String strFilter = (String)filterparams.get("FILTERKEY");
if(strFilter != null && !strFilter.equals(""))
{
    for(int i=list.size()-1; i>=0;i--)
    {
         resource = list.get(i);
         IPropertyName propname = new PropertyName("http://sapportals.com/xmlns/cm","metiertest");
         IProperty property = resource.getProperty(propname);

         if(property != null)
         {
             String value = property.getValueAsString();
             if(!value.equals(strFilter))
             {
                 list.remove(resource);
             }
         }
    }
}

Does anybody see an error in my code?

Because I cant find anything that appears to be wrong...

Thanks in advance

Kr

Wouter

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2008 at 07:44 AM

    I've found the problem.

    As you can see, the searchstring is being passed on through the parameters in the parameter named "FILTERKEY".

    This parameters returns null in my resourcefilter. I am however certain that it is being filled with a value in the "onSetFilters" method of my "FilterControl" class.

    So it is not being passed to my resourcefilter class.

    Can anybody think of a possible cause for this?

    Below is my code of the "onSetFilters" event.

    public WdfEvent onSetFilters(Event event) throws WdfException {
    		
    this.proxy.getDynamicPage().getPageContext().getDataForComponentId()  
    AbstractDataType filterString = this.getControlContext().getParentComponent().getDynPage().getPageContext().getDataForComponentId("dropdownvalues");
    		String searchString = filterString.getValueAsString();
    
    		IParameterName paramName = ParametersFactory.getParameterName("FILTERKEY");
    		
    		IParameterMap paramMap = ParametersFactory.newParameters();
    		
    		IParameterName paramNames[] = {paramName};   
    		IParameters parameters = (IParameters) paramMap.getParameters(paramNames);
    		//set filter parameters this will be passed into the Resource filter 
    		parameters.setParameter(paramName,searchString);
    	
    		IRendererStatus ris = null;
    		
    		try {
    			//IRendererStatus object has most of the list details
    			ris = ((IRendererStatus) this.proxy.getControlStatus(this.getCollectionRenderer().getID()));
    			if(ris != null){
    				//filter parameters set 
    				ris.setFilterParameters(parameters);
    				//parent collection defined which is the list that will be passed into Resource Filter 
    				//this will also invoke an actual filtering
    				ris.setParent((ICollection)this.getResource());
    			}
    			
    		} catch (WcmException e2) {
    			e2.printStackTrace();
    		}
    		 //filtering complete 
    		return null;
    	}
    

    I've even tried replacing the parameter "FILTERKEY" with a hardcoded string and it still is null when I read it in the resourcefilter class.

    I'm running out of ideas... :s

    Thanks in advance

    Kind regards

    Wouter

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 16, 2008 at 10:26 AM

    After debugging I found out that the parameters aren't put into the RenderStatus.

    So something is going wrong with this part of the code: But I can't figure out what..

    IRendererStatus ris = null;
    		
    		try {
    			//IRendererStatus object has most of the list details
    			ris = ((IRendererStatus) this.proxy.getControlStatus(this.getCollectionRenderer().getID()));
    			if(ris != null){
    				//filter parameters set 
    				ris.setFilterParameters(parameters);
    				//parent collection defined which is the list that will be passed into Resource Filter 
    				//this will also invoke an actual filtering
    				ris.setParent((ICollection)this.getResource());
    			}
    

    I tried running it on a EP 7.0 SP14 and there it works.

    It's just on the EP 7.0 SP17 that it isn't working.

    is there realy nobody who has an idea of what the problem might be?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 16, 2008 at 12:44 PM

    I debugged both applications at the same time and I've found a difference between them.

    when I get the collectionrender using

    ICollectionRenderer crenderer = (IcollectionRenderer)this.getCollectionRenderer();
    

    the type of the crenderer equals

    com.sapportals.wcm.rendering.collection.CollectionRendererStatus in the working application and

    com.sapportals.wcm.rendering.collection.cm.CollectionListRenderer

    when I then get the RendererStatus "ris" the type is also different in the two applications

    com.sapportals.wcm.rendering.collection.CollectionRendererStatus and

    com.sapportals.wcm.rendering.collection.JanusHeadedStatusFlipSide

    The JanusHeadedStatusFlipSide does not contain a field for the Filterparameters and this is the reason why my searchparameters aren't being passed on to my resourcefilter.

    So I figured out the problem. But I don't know how I can solve this.

    i need to get a CollectionRendererStatus object and not a JanusHeadedStatusFlipSide (what ever that may be) object.

    please help

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.