木兰CMS 6.2自定义字段
如何从JCR中获取Magnolia 6.2版的Custom Field Factory的项目值? 在较早版本的木兰中,在抽象的现场捕获实现中是属性项目。由于版本6.2。它不再在那里。
public class CustomFieldFactory extends AbstractFieldFactory<String, CustomFieldDefinition> {
@Inject
public CustomFieldFactory(CustomFieldDefinition definition, ComponentProvider componentProvider) {
super(definition, componentProvider);
}
public Component createFieldComponent() {
Object field;
if (((CustomFieldDefinition)this.getDefinition()).getRows() > 1) {
TextArea textArea = new TextArea();
textArea.setRows(((SalesVolumeFromDataHubFieldDefinition)this.getDefinition()).getRows());
field = textArea;
} else {
field = new TextField();
}
if (((CustomFieldDefinition)this.getDefinition()).getMaxLength() != -1) {
((AbstractTextField)field).setMaxLength(((CustomFieldDefinition)this.getDefinition()).getMaxLength());
MaxLengthIndicatorExtension.extend((AbstractTextField)field);
}
((AbstractTextField)field).setPlaceholder(((CustomFieldDefinition)this.getDefinition()).getPlaceholder());
return (Component)field;
}
}
How can I get the item value from JCR for custom field factory in Magnolia version 6.2?
In the earlier version of Magnolia, in Abstract FieldFactory implementations was the property Item item. Since version 6.2. it is no longer there.
public class CustomFieldFactory extends AbstractFieldFactory<String, CustomFieldDefinition> {
@Inject
public CustomFieldFactory(CustomFieldDefinition definition, ComponentProvider componentProvider) {
super(definition, componentProvider);
}
public Component createFieldComponent() {
Object field;
if (((CustomFieldDefinition)this.getDefinition()).getRows() > 1) {
TextArea textArea = new TextArea();
textArea.setRows(((SalesVolumeFromDataHubFieldDefinition)this.getDefinition()).getRows());
field = textArea;
} else {
field = new TextField();
}
if (((CustomFieldDefinition)this.getDefinition()).getMaxLength() != -1) {
((AbstractTextField)field).setMaxLength(((CustomFieldDefinition)this.getDefinition()).getMaxLength());
MaxLengthIndicatorExtension.extend((AbstractTextField)field);
}
((AbstractTextField)field).setPlaceholder(((CustomFieldDefinition)this.getDefinition()).getPlaceholder());
return (Component)field;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将
valueContext&lt; node&gt;
注入现场工厂构造函数。然后,您可以通过
在这里是一个测试示例。
You can inject
ValueContext<Node>
into the field factory constructor.Then you can retrieve it via
Here is a test example.