在首选项中保存动态字段值时出现问题 [英] Issue while saving the dynamic field values in the preferences

查看:90
本文介绍了在首选项中保存动态字段值时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在同一问题上发布了一个问题.但是我无法解决我的问题,也无法继续执行我的任务.

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.

我创建了一个可编辑的portlet,在配置页面中,我向他显示了从数据库中提取的动态问题.因此,出于相同的原因,我要迭代数组列表并按如下所示动态创建输入字段,

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.

当我尝试将这些动态字段值保存在首选项中时,通过将前缀添加为"preferences--"并将后缀添加为-",将输入语句的语法更改为正确的方式,如下所示,

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

我不知道上面的语句中什么语法错误.但是我无法在UI中看到标签名称.而不是为所有标签显示正确的标签名称,而是在UI上显示<%= columnVal%>.

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.

我正在liferay-portlet.xml中使用默认配置操作类,如下所述,

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.

推荐答案

从参考文献链接的评论部分:

From reference link's comment section:

根据JSP 2.1规范的多个表达式和 表达式和字符串常量是不允许的.

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

这篇关于在首选项中保存动态字段值时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆