【问题标题】:How to pass input text value as portlet param如何将输入文本值作为 portlet 参数传递
【发布时间】:2016-02-02 02:21:52
【问题描述】:
我有一个 portlet 页面:
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<portlet:resourceURL var="resourceUrl">
<portlet:param name="startDate" value="" />
</portlet:resourceURL>
<input id="startdateexportaging" type="text" />
<a style="font-size: 15px;" href="${resourceUrl}" >URL</a>
点击resourceUrl的链接时,如何将startdateexportaging的内容作为portlet参数 startDate传递?
【问题讨论】:
标签:
liferay
liferay-6
portlet
【解决方案1】:
单击链接后,您可以使用onclick 处理程序将内容添加到 URL。但这会很麻烦,容易出错并且没有必要。
您应该将您的 input 添加到 form 并将 URL 定义为操作参数:
<aui:form action="<%= resourceUrl.toString() %>" method="get">
<aui:input name="startDate" type="text" />
<aui:button value="Download" type="submit" />
</aui:form>
(如果你不使用 AUI - 你也可以使用简单的 HTML 标签)
此解决方案的另一个优点:按钮而不是链接使用户更容易理解来自文本字段的内容已提交。将其与 SO 上的链接和按钮的使用进行比较 - 如果您输入一些信息,您必须点击一个按钮。
搜索引擎更容易解析网站,因为它们会尝试跟踪链接 - 但忽略按钮。