Issue while saving the dynamic field values in the preferences
Asked Answered
P

1

1

I have already posted one question on the same issue. But I'm not able to solve my issue and not able to move forward in my task.

I have created a editable portlet where in the configuration page I am showing he dynamic questions which are fetching form the database. So for the same reason I am iterating my array list and creating the input fields dynamically as follows,

Iterator<String> itr = al.iterator();
 while(itr.hasNext())
 {
         String columnVal = itr.next();
         columnVal = columnVal.trim().toLowerCase();
         %>
         <aui:input name="<%=columnVal%>" type="checkbox" />
         <%
 }

With the above code the fields are creating dynamically with proper labels and seems to be fine.

When I try to save these dynamic field values in the preference I changed my input statement syntax to the proper way by adding the prefix as "preferences--" and suffix as "--" as shown below,

<aui:input name="preferences--<%=columnVal%>--" type="checkbox" />

I don't know what syntax is wrong in the above statement. But I am not able to see the label names in UI. instead of showing the proper label names for all labels it is showing <%=columnVal%> on UI.

I am using default configuration action class in my liferay-portlet.xml as mentioned below,

<configuration-action-class>com.liferay.portal.kernel.portlet.DefaultConfigurationAction</configuration-action-class>

Can any one please correct my syntax and help me to save my dynamic field values in the preferences.

Pricket answered 14/7, 2015 at 13:34 Comment(5)
Have you verified html source generated on browser, if these input elements are having proper name with prefix as preferencess--?Kindling
I checked in the firebug on the browser. the name attribute is showing something like this, name="_86_preferences--<%=columnName%>--Checkbox".Pricket
What can I do now. Please suggest some thing to resolve this issue. Generally how can we give the name attribute for dynamic fields?Pricket
Simply Use, <aui:input name='<%="preferences--"+columnVal+"--"%>' type="checkbox" />Kindling
Would be great if this was converted as an answer to help the community and also it would nice if @manjunathramigani can also mark as an answer the previous post which lead to this question. Thank you all.Zhang
K
2

From reference link's comment section:

According to JSP 2.1 Specification multiple expressions and mixing of expressions and string constants are not permitted.

So you have to use below code in your case:

<aui:input name='<%="preferences--"+columnVal+"--"%>' type="checkbox" />
Kindling answered 15/7, 2015 at 13:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.