_hospital_WAR_hospitalportlet_前面Id的字符串<input>只不过是 portlet 命名空间。
如果您使用标签,这只会添加到您<input>的name&id属性之前,如果您只使用普通的 html标签<aui:input>,则name&属性不会更改。id<input>
但由于使用它是一种很好的做法,<aui:input>您可以执行以下操作来获取 javascript 代码中的 portlet-namespace:
如果您在 JSP 中使用 javascripts,即使用 inside<script> .. </script>或<aui:script> .. </aui:script>然后您可以使用<portlet:namespace />or<%= renderResponse.getNamespace() %>获取_hospital_WAR_hospitalportlet_您的 javascript 中的字符串,例如。
jQuery("#<portlet:namespace />username").val();
// Or
jQuery("#<%= renderResponse.getNamespace() %>username").val();
但是,如果您使用的是*.js文件,那么我建议您将命名空间作为参数传递给js文件中的 javascript 函数:
function changeValues(portletNamespace) { // this function is in a js file
jQuery("#" + portletNamespace + "username").val("Lets change");
}
从 JSP 调用此函数:
<input type="button" onClick="changeValues('<portlet:namespace />')" />
希望这可以帮助。我不知道是否有办法直接通过 Liferay 定义的一些 javascript 函数来获取namespaceor 。portletId如果你得到类似的东西,你可以把它贴在这里,这将非常有帮助。