【问题标题】:How can I set up a Dropdown List using Template Composer Annotation in Hippo CMS?如何在 Hippo CMS 中使用 Template Composer Annotation 设置下拉列表?
【发布时间】:2015-07-30 16:02:59
【问题描述】:

目前正在处理一个简单的组件,我需要下拉菜单的显示名称为:

一、三、五

但是,我需要该值实际上等于这些显示名称的整数值。一 = (int) 1,三 = (int) 3,五 = (int) 5。

package com.authx.components;

import org.hippoecm.hst.core.parameters.DropDownList;
import org.hippoecm.hst.core.parameters.Parameter;

public interface PressEventComponentInfo {

    @Parameter(name = "number", required = true, displayName = "Release Number",       defaultValue="three")
    @DropDownList({"one", "three", "five"})
    String getNumber();
}

【问题讨论】:

    标签: annotations hippocms


    【解决方案1】:

    您可以通过将 i18n 用于属性值来做到这一点。

    对于下拉字段,您可以使用参数名称后跟斜杠,然后再次使用参数值作为键(例如,在您的示例中,“number/1=One”)。

    + site
        + src
            + main
                + java
                |   +com.authx.components.PressEventComponentInfo
                + resources
                    +com.authx.components
                        - PressEventComponentInfo.properties
    

    您可以在HST Component Parameters documentation pagechannel info page 上找到有关此主题的更多信息和一些示例。

    并添加以下属性:

    number/1=One
    number/3=Three
    number/5=Five
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-27
      • 2011-07-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多