Issue while saving the dynamic field values in the preferences

五迷三道 提交于 2019-12-13 00:42:15

问题


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.


回答1:


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" />


来源:https://stackoverflow.com/questions/31408211/issue-while-saving-the-dynamic-field-values-in-the-preferences

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!