在Liferay中显示真/假自定义字段为复选框

问题描述:

当您创建类型为true/false的布尔自定义字段时,它会显示为下拉框,其中true和false为值。当我去编辑字段并没有看到允许更改显示类型的选项时。我希望将此字段呈现为复选框。任何建议都非常感谢。在Liferay中显示真/假自定义字段为复选框

不幸的是,我无法找到这种类型的字段的任何配置选项,因为它与其他字段一样。我发现将true/false设置为复选框的方式是从呈现自定义属性的taglib中覆盖jsp。 Here我已经描述了需要做的事情。

http://liferay.bdedov.eu/2012/02/render-truefalse-custom-field-type-as.html

干杯!

一种方法可以在html\taglib\ui\custom_attribute\创建jsppage.jsp并更换selectcheckbox

<c:choose> 
    <c:when test="<%= type == ExpandoColumnConstants.BOOLEAN %>"> 
     <% Boolean curValue=(Boolean)value; if (curValue==n ull) { curValue=(Boolean)defaultValue; } curValue=P aramUtil.getBoolean(request, "ExpandoAttribute--" + escapedName + "--", curValue); %> 
      <select id="<%= randomNamespace %><%= escapedName %>" name="<portlet:namespace />ExpandoAttribute--<%= escapedName %>--"> 
       <option <%=c urValue ? "selected" : "" %>value="1"> 
        <liferay-ui:message key="true" /> 
       </option> 
       <option <%=! curValue ? "selected" : "" %>value="0"> 
        <liferay-ui:message key="false" /> 
       </option> 
      </select> 
    </c:when> 
</c:choose>