Im using the Search and Promote cloud service, and I make use of Facet API to retrieve the facet values.
My use case is like I have a facet "state"(state is a tag which is created under etc/tags folder) and I tagged this facet to my page.
If I say facet.getItems, I will get all the facet items of the facet "State", and in my case each facet item is a checkbox, so I iterate over each facet and get the query string of that facet.
when I click one of the checkboxes(facetitems), I will append the query string from the checkbox(facetitem) to the search query.
Im not having any problem when I click the first checkbox, Im able to get the query string, however when I click on another checkbox(having the first one already checked), Im not getting the facet value of the second checkbox. So may I know if search and promote allow only one facet item to be selected? Below is my code snippet.
<%@page import="com.day.cq.wcm.api.WCMMode,
com.day.cq.searchpromote.Search,
com.day.cq.searchpromote.xml.result.FacetList,
com.day.cq.searchpromote.xml.result.Facet,
com.day.cq.searchpromote.xml.result.FacetValue,
com.day.text.Text"%>
String facetName = properties.get("cq:facetname", ""); (in my case facetName is a state which is actually a tag defined under etc/tags)
Facet facet = search.getFacet(facetName);
for(FacetValue facetValue: facet.getItems()) { //iterating over all the checkboxes )
String queryString = xssAPI.getValidHref(facetValue.getQueryString()); //this is returning value only if I check one check box, it is not returning any querystring for the second checkbox.
%>
<li>
<input onclick="alert('queryString'+'<%= queryString %>'); window.location = '<%= queryString %>';" type="checkbox" name="<%= valueLabelAttr %>" /> </li>
<%
}
%>
The above code snippet is working only if I check one check box, if I select the second checkbox, Im getting null value for the second check box, so my query is formed for only the first checkbox. So just want to know if search and promote allow only one facet item(check box) to be selected?