Hi folks,
I developed a custom suggestion provider based of these instructions "https://help.sap.com/saphelp_nw73/helpdata/de/4e/133ef5ff12001ce10000000a42189c/content.htm".
The suggestion provider is working until the point, that it will not load the requested resource after clicking on an item from the suggestion list of the search bar. A new window opens with the correct url to the resource, but only a "HTTP 400"-Error shows up. If I enter the url manually in the address bar of IE or Firefox it will open the resource.
The standard sap navigation suggestion works. So it have to be a problem with my implementation.
Here are my relevant source codes where i define the suggestions:
SuggestionProvider: ->
public List<ISuggestion> search(String searchTerm, IUser user, Locale locale, ISuggestionFilter filter) { ...... List<ISuggestion> suggestions = new ArrayList<ISuggestion>(); IResource res = result.getResource(); try { IURLGeneratorService ug = (IURLGeneratorService) ResourceFactory.getInstance().getServiceFactory().getService(IServiceTypesConst.URLGENERATOR_SERVICE); RID rid = res.getAccessRID(); IUriReference uriRef = ug.getResourcePageUri(PathKey.CONTENT_ACCESS_PATH , rid, null); IHierarchicalUri uri = ug.createAbsoluteUri(uriRef); String path = uri.toExternalForm(); Suggestion suggestion = new Suggestion(); suggestion.setTitle(res.getDisplayName()); suggestion.setTooltip(path); suggestion.setUrl(path); suggestion.setSuggestionProvider("MyID"); suggestions.add(suggestion); } catch (ResourceException e) { log.errorT(e.getLocalizedMessage()); } catch (WcmException e) { e.printStackTrace(); } ..... return suggestions; }
Suggestion:
import java.util.Map; import com.sap.portal.suggestion.providers.ISuggestion; import com.sap.portal.suggestion.providers.SuggestionProvidersConstants; public class Suggestion implements ISuggestion { private String title = null; private String category = null; private String path = null; private String url = null; private int launchMode = 3; @SuppressWarnings("unchecked") private Map additionalAttributes = null; private String winFeature = SuggestionProvidersConstants.WIN_FEATURES; private int winMode = 3; private SuggestionProvidersConstants.SuggestionProvidersNavigationType navigationType = SuggestionProvidersConstants.SuggestionProvidersNavigationType.INTERNAL; private String tooltip = null; private String suggestionProviderId = null; public int getWinMode() { return this.winMode; } public void setWinMode(int winMode) { this.winMode = winMode; } public String getWinFeature() { return winFeature; } @Override public int getLaunchMode() { return this.launchMode; } @Override public String getSuggestionProviderID() { return this.suggestionProviderId; } @Override public String getTitle() { return this.title; } @Override public String getTooltip() { return this.tooltip; } @Override public String getUrl() { return this.url; } public void setTitle(String title) { this.title = title; } public void setTooltip(String tooltip) { this.tooltip = tooltip; } public void setUrl(String url) { this.url = url; } public void setSuggestionProvider(String providerId) { this.suggestionProviderId = providerId; } public String getCategory() { return this.category; } public void setCategory(String category) { this.category = category; } public String getPath() { return this.path; } public void setPath(String path) { this.path = path; } @SuppressWarnings("unchecked") public Map getAdditionalAttributes() { return this.additionalAttributes; } @SuppressWarnings("unchecked") public void setAdditionalAttributes(Map additionalAttributes) { this.additionalAttributes = additionalAttributes; } public SuggestionProvidersConstants.SuggestionProvidersNavigationType getNavigationType() { return this.navigationType; } public void setNavigationType( SuggestionProvidersConstants.SuggestionProvidersNavigationType navigationType) { this.navigationType = navigationType; } }
Does somebody have the same problem or maybe a solution?
Thanks in advance
Regards
David