1

我有这个 XML 代码:

<extension id="free_textfield" label="Description notes" readOnly="true"/>

现在我想在那里添加一个参数

<extension id="free_textfield" label="Description notes" readOnly="true" text="sample string maybe with links"/>

现在我想在我的 Java 类中使用这个文本参数:

    public class FormExtensionExample implements IFormExtension {
    public static final String ID = "free_textfield";

    @Inject
    private IDataService service;

    @Override
    public String render(IPObject object, Map<String, String> attributes) {
        
        return null;
    }

我怎样才能做到这一点?

谢谢你的帮助!

4

1 回答 1

0

您在表单配置中指定的所有属性如下所示:

<extension id="free_textfield" label="Description notes" readOnly="true" text="sample string maybe with links"/>

可以在您必须覆盖attributes的方法的 map 参数中找到:render()

@Override
public String render(IPObject object, Map<String, String> attributes) {

    // here you go:
    String myAttributeValue = attributes.get("text");
    // the following will print "sample string maybe with links"
    System.out.println(myAttributeValue);
    
    return null;
}
于 2021-01-26T14:04:50.783 回答