如何从 liferay portlet 参考中的 jsp 到 java 控制器 class 的下拉列表中获取选定值

How to get selected value from drop down list in one jsp to java controller class in liferay portlet references

我正在使用 Liferay,因为 platform.I 创建了包含 2 个值的下拉列表(true/false(默认选择 "false"))一旦我点击更新按钮,它应该在首选项字段中更新(即下拉列表)。我正在使用下面的代码,但它给出了空值。我无法 read/get 选择从 EditPreferences.jsp 到 EditController.java 的下拉值。如果可以将值从 Editpreferences.jsp 渲染到 EditConytroller Class 那么这对我来说应该没问题。谢谢你的任何建议。

这是我在 EditPreferences.jsp

中的代码
<portlet:defineObjects />
<script type="text/javascript" src="js/jquery.js"></script>
<%@page import="javax.portlet.PortletPreferences" %>
<%
    PortletPreferences pref = renderRequest.getPreferences();

    String IsCollege = pref.getValue("IsCollege","");
    Locale locale = renderRequest.getLocale();
    ResourceBundle bundle = portletConfig.getResourceBundle(locale);
    String updated = (String) request.getAttribute ("preferences-updated");
    if (updated != null && updated.equals ("true")) {

%>

  <div class="portlet-msg-info">
    <liferay-ui:message key="preferences-update-successful" />
  </div>
 <% 
 } 
 %>

  <portlet:actionURL var="actionOneMethodURL">

     <portlet:param name="action" value="actionOne"></portlet:param>

 </portlet:actionURL>

<form  method="POST" action="${actionOneMethodURL}" >
 <tr>
    <td>
        IsCollege:
    </td>

      <td>
        <select id="IsCollege">
            <option value="false" selected="selected">False</option>
            <option value="true">True</option>
       </select>
     </td>
    </tr>
    <tr>
        <td colspan=2>
        <input type="submit" id="updateBtn" value="Update">
        </td>
    </tr>
 </form>

EditController.java

 @ActionMapping(params = "action=actionOne")
  public void setPublisherPref(ActionRequest request, ActionResponse response)
        throws Exception {
    PortletPreferences pref = request.getPreferences();

   String IsCollege = ParamUtil.getString(request, "IsCollege", "");
   pref.setValue("IsCollege", IsCollege);
   pref.store();

    request.setAttribute("preferences-updated", "true");

}

select 标签缺少名称属性。指定的 id 不影响参数绑定。此外,该名称必须以 portlet 名称空间为前缀。

<select name="<portlet:namespace/>IsCollege">

与其手动渲染完整的 HTML,下次您可能想要使用 ui 或 liferay-ui 标签库。