In jsp i am making use of html form to display and select list of brands. Once i click submit button after selecting some brands, Accesssing those in controller layer that time giving null result.
This is form displaying brands
<portlet:renderURL var="productFilterURL" >
<portlet:param name="mvcRenderCommandName" value="<%=MVCCommandNames.VIEW_PRODUCTS %>" />
<portlet:param name="filter" value="true" />
</portlet:renderURL>
<form action="${productFilterURL}" method="post">
<div class="filter-box" >
<p class="filter-head" >BRANDS</p>
<c:forEach items="<%= brands %>" var="brand">
<div class="check-box" >
<input id="${brand}" class="chk-bx" type="checkbox" name="selectedBrand" value="${brand}" />
<label for="${brand}" class="lbl-txt">${brand}</label>
</div>
</c:forEach>
</div>
<div class="submit-div">
<button class="submit-btn" type="submit">Submit </button>
</div>
</form>
After this i am trying to fetch brands in following ways like this
String[] checkedBrands = (String[]) renderRequest.getAttribute("selectedBrand");
returning null;
String[] checkedPrices = renderRequest.getParameterValues("selectedPrice");
String[] checkedPrices = ParamUtil.getStringValues(renderRequest, "selectedBrand");
returning empty array;
When evaluate renderRequest it has data but while fetching getting empty. Below lines are renderRequest evaluation result..
_fileParameters = {LinkedHashMap@40433} size = 0
_liferayServletRequest = {LiferayServletRequest@40434}
_regularParameters = {LinkedHashMap@40435} size = 2
"selectedBrand" -> {ArrayList@40442} size = 2
key = "selectedBrand"
value = {ArrayList@40442} size = 2
0 = "Roadster"
1 = "LOCOMOTIVE"
How to overcome this issue, give me solution thank you.
In the portlet world, parameters are typically namespaced, to attribute them to the proper application (as many applications can share the page and might otherwise step on each others if they use overlapping names).
While you can disable the required namespacing somehow, I recommend to add the namespace in HTML. On the Java side, the namespace is automagically removed, so you can access the parameters with the un-namespaced value: