Xpages 如何创建具有许多复杂类型的UI控件
我仍在尝试UI控制,如以下帖子: 现在,当我试图将子复杂类型集合包含到另一个复杂类型集合中时,遇到了一些问题 我想拥有这样的房产:Xpages 如何创建具有许多复杂类型的UI控件,xpages,Xpages,我仍在尝试UI控制,如以下帖子: 现在,当我试图将子复杂类型集合包含到另一个复杂类型集合中时,遇到了一些问题 我想拥有这样的房产: Could not generate a .java file for the page /index.xsp: Could not find a method for the collection property <submenu> on the object <menu>, to add the value <submenu&g
Could not generate a .java file for the page /index.xsp: Could not find a method for the collection property <submenu> on the object <menu>, to add the value <submenu>. index.xsp testing.nsf/XPages line 1 XPages Problem
航行
菜单+-
菜单[0]//下拉列表请查看下面的菜单[0]
菜单[1]
每个菜单都有如下子属性:
Could not generate a .java file for the page /index.xsp: Could not find a method for the collection property <submenu> on the object <menu>, to add the value <submenu>. index.xsp testing.nsf/XPages line 1 XPages Problem
菜单[0]
链接
偶像
名称
子菜单+-
子菜单[0]//有关下拉列表,请查看下面的子菜单[0]
子菜单[1]
菜单[1]
链接
偶像
名称
最后。。这里是子菜单的属性
子菜单[0]
链接
名称
子菜单[1]
链接
名称
这里是我的这个组件和复杂类型的脚本
// 1. NAVIGATION COMPONENT
package com.forte.component;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import com.forte.complex.Menu;
import com.ibm.xsp.util.FacesUtil;
public class ForteNavigation extends UIComponentBase {
public static final String RENDERER_TYPE = "com.forte.Navigation";
private String navigation;
private Menu menu;
public ForteNavigation() {
super();
setRendererType(RENDERER_TYPE);
}
@Override
public String getFamily() {
return RENDERER_TYPE;
}
// NAVIGATION
public String getNavigation() {
if (null != this.navigation) {
return this.navigation;
}
ValueBinding _vb = getValueBinding("navigation");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setNavigation(String navigation){
this.navigation = navigation;
}
// MENU
public Menu getMenu() {
if (null != this.menu) {
return this.menu;
}
ValueBinding _vb = getValueBinding("menu");
if (_vb != null) {
return (Menu) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setMenu(Menu menu){
this.menu = menu;
}
@Override
public void restoreState(FacesContext _context, Object _state) {
Object _values[] = (Object[]) _state;
super.restoreState(_context, _values[0]);
this.navigation = (String) FacesUtil.objectFromSerializable(_context, this, _values[1]);
this.menu = (Menu) FacesUtil.objectFromSerializable(_context, this, _values[2]);
}
@Override
public Object saveState(FacesContext _context) {
Object _values[] = new Object[3];
_values[0] = super.saveState(_context);
_values[1] = FacesUtil.objectToSerializable(_context, navigation);
_values[2] = FacesUtil.objectToSerializable(_context, menu);
return _values;
}
}
// 2. MENU COMPLEX TYPE
package com.forte.complex;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import com.ibm.xsp.complex.ValueBindingObjectImpl;
import com.ibm.xsp.util.FacesUtil;
public class Menu extends ValueBindingObjectImpl {
private String icon;
private String link;
private Boolean visible;
private String name;
private SubMenu subMenu;
public Menu() {
}
// ICON
public String getIcon() {
if (null != this.icon) {
return this.icon;
}
ValueBinding _vb = getValueBinding("icon");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setIcon(String icon){
this.icon = icon;
}
// LINK
public String getLink() {
if (null != this.link) {
return this.link;
}
ValueBinding _vb = getValueBinding("link");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setLink(String link){
this.link = link;
}
// VISIBLE
public Boolean getVisible() {
if (null != this.visible) {
return this.visible;
}
ValueBinding _vb = getValueBinding("visible");
if (_vb != null) {
return (Boolean) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setVisible(boolean visible){
this.visible = visible;
}
// NAME
public String getName() {
if (null != this.name) {
return this.name;
}
ValueBinding _vb = getValueBinding("name");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setName(String name){
this.name = name;
}
// ICON
public Object getSubMenu() {
if (null != this.subMenu) {
return this.subMenu;
}
ValueBinding _vb = getValueBinding("subMenu");
if (_vb != null) {
return (Object) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setSubMenu(SubMenu subMenu){
this.subMenu = subMenu;
}
@Override
public void restoreState(FacesContext _context, Object _state) {
Object _values[] = (Object[]) _state;
super.restoreState(_context, _values[0]);
this.icon = (String) FacesUtil.objectFromSerializable(_context, getComponent(), _values[1]);
this.link = (String) FacesUtil.objectFromSerializable(_context, getComponent(), _values[2]);
this.visible = (Boolean) FacesUtil.objectFromSerializable(_context, getComponent(), _values[3]);
this.name = (String) FacesUtil.objectFromSerializable(_context, getComponent(), _values[4]);
this.subMenu = (SubMenu) FacesUtil.objectFromSerializable(_context, getComponent(), _values[5]);
}
@Override
public Object saveState(FacesContext _context) {
Object _values[] = new Object[6];
_values[0] = super.saveState(_context);
_values[1] = FacesUtil.objectToSerializable(_context, icon);
_values[2] = FacesUtil.objectToSerializable(_context, link);
_values[3] = FacesUtil.objectToSerializable(_context, visible);
_values[4] = FacesUtil.objectToSerializable(_context, name);
_values[5] = FacesUtil.objectToSerializable(_context, subMenu);
return _values;
}
}
// 3. SUBMENU COMPLEX TYPE
package com.forte.complex;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import com.ibm.xsp.complex.ValueBindingObjectImpl;
import com.ibm.xsp.util.FacesUtil;
public class SubMenu extends ValueBindingObjectImpl {
private String link;
private Boolean visible;
private String name;
public SubMenu() {
}
// LINK
public String getLink() {
if (null != this.link) {
return this.link;
}
ValueBinding _vb = getValueBinding("link");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setLink(String link){
this.link = link;
}
// VISIBLE
public Boolean getVisible() {
if (null != this.visible) {
return this.visible;
}
ValueBinding _vb = getValueBinding("visible");
if (_vb != null) {
return (Boolean) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setVisible(Boolean visible){
this.visible = visible;
}
// NAME
public String getName() {
if (null != this.name) {
return this.name;
}
ValueBinding _vb = getValueBinding("name");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setName(String name){
this.name = name;
}
@Override
public void restoreState(FacesContext _context, Object _state) {
Object _values[] = (Object[]) _state;
super.restoreState(_context, _values[0]);
this.link = (String) FacesUtil.objectFromSerializable(_context, getComponent(), _values[2]);
this.visible = (Boolean) FacesUtil.objectFromSerializable(_context, getComponent(), _values[3]);
this.name = (String) FacesUtil.objectFromSerializable(_context, getComponent(), _values[4]);
}
@Override
public Object saveState(FacesContext _context) {
Object _values[] = new Object[4];
_values[0] = super.saveState(_context);
_values[1] = FacesUtil.objectToSerializable(_context, link);
_values[2] = FacesUtil.objectToSerializable(_context, visible);
_values[3] = FacesUtil.objectToSerializable(_context, name);
return _values;
}
}
// LAST.. NAVIGATION.XSP-CONFIG
<faces-config>
<faces-config-extension>
<namespace-uri>http://fortedynamic.org/xsp/control</namespace-uri>
<default-prefix>forte</default-prefix>
</faces-config-extension>
<component>
<description>Forte Navigation</description>
<display-name>Navigation</display-name>
<component-type>com.forte.Navigation</component-type>
<component-class>com.forte.component.ForteNavigation</component-class>
<component-extension>
<component-family>com.forte.Navigation</component-family>
<renderer-type>com.forte.Navigation</renderer-type>
<tag-name>navigation</tag-name>
<designer-extension>
<in-palette>true</in-palette>
<category>Forte Smart UI</category>
<render-markup><?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xp_1="http://www.ibm.com/xsp/coreex">
<xp:radioGroup layout="<%=
this.navigation=='left'?'pageDirection':'lineDirection'
%>" style="width:155px;height:27px" >
<xp:selectItem itemLabel="<%=
this.navigation=='left'?'Left Navigation':' '
%>" ></xp:selectItem>
<xp:selectItem itemLabel=" "></xp:selectItem>
<xp:selectItem itemLabel="<%=
this.navigation=='left'?' ':'Top Navigation'
%>" ></xp:selectItem>
</xp:radioGroup>
</xp:view></render-markup>
</designer-extension>
</component-extension>
<property>
<description>Navigation</description>
<display-name>Navigation</display-name>
<property-name>navigation</property-name>
<property-class>string</property-class>
<property-extension>
<designer-extension>
<category>forte</category>
<editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
<editor-parameter>top
left
</editor-parameter>
</designer-extension>
</property-extension>
</property>
<property>
<description>Menu</description>
<display-name>Menu</display-name>
<property-name>menu</property-name>
<property-class>java.util.List</property-class>
<property-extension>
<allow-run-time-binding>false</allow-run-time-binding>
<collection-property>true</collection-property>
<property-item-class>com.forte.complex.Menu</property-item-class>
<property-add-method>addMenu</property-add-method>
<designer-extension>
<category>forte</category>
</designer-extension>
</property-extension>
</property>
</component>
<complex-type>
<description>Menu</description>
<display-name>Menu</display-name>
<complex-id>com.forte.complex.menu</complex-id>
<complex-class>com.forte.complex.Menu</complex-class>
<property-extension>
<container-class>java.util.Collection</container-class>
<collection-property>true</collection-property>
</property-extension>
<property>
<property-name>icon</property-name>
<property-class>string</property-class>
</property>
<property>
<property-name>link</property-name>
<property-class>string</property-class>
</property>
<property>
<property-name>name</property-name>
<property-class>string</property-class>
</property>
<property>
<property-name>visible</property-name>
<property-class>boolean</property-class>
<property-extension>
<designer-extension>
<editor>com.ibm.std.BooleanCheckBox</editor>
</designer-extension>
</property-extension>
</property>
<property>
<property-name>submenu</property-name>
<property-class>java.util.List</property-class>
<property-extension>
<allow-run-time-binding>false</allow-run-time-binding>
<collection-property>true</collection-property>
<property-item-class>com.forte.complex.SubMenu</property-item-class>
<property-add-method>addSubMenu</property-add-method>
</property-extension>
</property>
<complex-extension>
<tag-name>menu</tag-name>
</complex-extension>
</complex-type>
<complex-type>
<description>Sub Menu</description>
<display-name>Sub Menu</display-name>
<complex-id>com.forte.complex.submenu</complex-id>
<complex-class>com.forte.complex.SubMenu</complex-class>
<property-extension>
<container-class>java.util.Collection</container-class>
<collection-property>true</collection-property>
</property-extension>
<property>
<property-name>link</property-name>
<property-class>string</property-class>
</property>
<property>
<property-name>name</property-name>
<property-class>string</property-class>
</property>
<property>
<property-name>visible</property-name>
<property-class>boolean</property-class>
<property-extension>
<designer-extension>
<editor>com.ibm.std.BooleanValue</editor>
</designer-extension>
</property-extension>
</property>
<complex-extension>
<tag-name>submenu</tag-name>
</complex-extension>
</complex-type>
</faces-config>
当我尝试保存后,将带有菜单和子菜单的UI控件添加到index.xsp。提示出现如下错误:
Could not generate a .java file for the page /index.xsp: Could not find a method for the collection property <submenu> on the object <menu>, to add the value <submenu>. index.xsp testing.nsf/XPages line 1 XPages Problem
如何解决这个问题 我在这里发布我对这个问题的回答:
// COMPLEX MENU.JAVA
package com.forte.complex;
import java.util.ArrayList;
import java.util.List;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import com.ibm.xsp.complex.ValueBindingObjectImpl;
import com.ibm.xsp.util.StateHolderUtil;
public class Menu extends ValueBindingObjectImpl {
private String id;
private String icon;
private String link;
private String target;
private Boolean visible;
private String name;
private List<SubMenu> subMenu;
public Menu() {
}
// ID
public String getId() {
if (null != this.id) {
return this.id;
}
ValueBinding _vb = getValueBinding("id");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setId(String id){
this.id = id;
}
// ICON
public String getIcon() {
if (null != this.icon) {
return this.icon;
}
ValueBinding _vb = getValueBinding("icon");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setIcon(String icon){
this.icon = icon;
}
// LINK
public String getLink() {
if (null != this.link) {
return this.link;
}
ValueBinding _vb = getValueBinding("link");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setLink(String link){
this.link = link;
}
// TARGET
public String getTarget() {
if (null != this.target) {
return this.target;
}
ValueBinding _vb = getValueBinding("target");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setTarget(String target){
this.target = target;
}
// VISIBLE
public Boolean getVisible() {
if (null != this.visible) {
return this.visible;
}
ValueBinding _vb = getValueBinding("visible");
if (_vb != null) {
return (Boolean) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setVisible(boolean visible){
this.visible = visible;
}
// NAME
public String getName() {
if (null != this.name) {
return this.name;
}
ValueBinding _vb = getValueBinding("name");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setName(String name){
this.name = name;
}
// SUB MENU
public List<SubMenu> getSubMenu() {
return this.subMenu;
}
public void addSubMenu(SubMenu child){
if(subMenu==null){
subMenu = new ArrayList<SubMenu>();
}
subMenu.add(child);
}
@Override
public void restoreState(FacesContext _context, Object _state) {
Object _values[] = (Object[]) _state;
super.restoreState(_context, _values[0]);
this.id = (String) _values[1];
this.icon = (String) _values[2];
this.link = (String) _values[3];
this.visible = (Boolean) _values[4];
this.name = (String) _values[5];
this.target = (String) _values[6];
this.subMenu = StateHolderUtil.restoreList(_context, getComponent(), _values[5]);
}
@Override
public Object saveState(FacesContext _context) {
Object _values[] = new Object[8];
_values[0] = super.saveState(_context);
_values[1] = id;
_values[2] = icon;
_values[3] = link;
_values[4] = visible;
_values[5] = name;
_values[6] = target;
_values[7] = StateHolderUtil.saveList(_context, subMenu);
return _values;
}
}
// COMPLEX SUBMENU.JAVA
package com.forte.complex;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import com.ibm.xsp.complex.ValueBindingObjectImpl;
public class SubMenu extends ValueBindingObjectImpl {
private String id;
private String link;
private Boolean visible;
private String name;
private String target;
public SubMenu() {
}
// ID
public String getId() {
if (null != this.id) {
return this.id;
}
ValueBinding _vb = getValueBinding("id");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setId(String id){
this.id = id;
}
// LINK
public String getLink() {
if (null != this.link) {
return this.link;
}
ValueBinding _vb = getValueBinding("link");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setLink(String link){
this.link = link;
}
// VISIBLE
public Boolean getVisible() {
if (null != this.visible) {
return this.visible;
}
ValueBinding _vb = getValueBinding("visible");
if (_vb != null) {
return (Boolean) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setVisible(boolean visible){
this.visible = visible;
}
// TARGET
public String getTarget() {
if (null != this.target) {
return this.target;
}
ValueBinding _vb = getValueBinding("target");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setTarget(String target){
this.target = target;
}
// NAME
public String getName() {
if (null != this.name) {
return this.name;
}
ValueBinding _vb = getValueBinding("name");
if (_vb != null) {
return (String) _vb.getValue(FacesContext.getCurrentInstance());
}
return null;
}
public void setName(String name){
this.name = name;
}
@Override
public void restoreState(FacesContext _context, Object _state) {
Object _values[] = (Object[]) _state;
super.restoreState(_context, _values[0]);
this.id = (String) _values[1];
this.link = (String) _values[2];
this.visible = (Boolean)_values[3];
this.target = (String) _values[4];
this.name = (String) _values[5];
}
@Override
public Object saveState(FacesContext _context) {
Object _values[] = new Object[6];
_values[0] = super.saveState(_context);
_values[1] = id;
_values[2] = link;
_values[3] = visible;
_values[4] = target;
_values[5] = name;
return _values;
}
}
<faces-config>
<faces-config-extension>
<namespace-uri>http://fortedynamic.org/xsp/control</namespace-uri>
<default-prefix>forte</default-prefix>
</faces-config-extension>
<component>
<description>Forte Navigation</description>
<display-name>Navigation</display-name>
<component-type>com.forte.Navigation</component-type>
<component-class>com.forte.component.ForteNavigation</component-class>
<component-extension>
<component-family>com.forte.Navigation</component-family>
<renderer-type>com.forte.Navigation</renderer-type>
<tag-name>navigation</tag-name>
<designer-extension>
<in-palette>true</in-palette>
<category>Forte Smart UI</category>
<render-markup><?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xp_1="http://www.ibm.com/xsp/coreex">
<xp:radioGroup layout="<%=
this.navigation=='left'?'pageDirection':'lineDirection'
%>" style="width:155px;height:27px" >
<xp:selectItem itemLabel="<%=
this.navigation=='left'?'Left Navigation':' '
%>" ></xp:selectItem>
<xp:selectItem itemLabel=" "></xp:selectItem>
<xp:selectItem itemLabel="<%=
this.navigation=='left'?' ':'Top Navigation'
%>" ></xp:selectItem>
</xp:radioGroup>
</xp:view></render-markup>
</designer-extension>
</component-extension>
<property>
<description>Navigation</description>
<display-name>Navigation</display-name>
<property-name>navigation</property-name>
<property-class>string</property-class>
<property-extension>
<designer-extension>
<category>forte</category>
<editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
<editor-parameter>top
left
</editor-parameter>
</designer-extension>
</property-extension>
</property>
<property>
<description>Menu</description>
<display-name>Menu</display-name>
<property-name>menu</property-name>
<property-class>java.util.List</property-class>
<property-extension>
<allow-run-time-binding>false</allow-run-time-binding>
<collection-property>true</collection-property>
<property-item-class>com.forte.complex.Menu</property-item-class>
<property-add-method>addMenu</property-add-method>
<designer-extension>
<category>forte</category>
</designer-extension>
</property-extension>
</property>
</component>
<complex-type>
<description>Menu</description>
<display-name>Menu</display-name>
<complex-id>com.forte.complex.menu</complex-id>
<complex-class>com.forte.complex.Menu</complex-class>
<property-extension>
<container-class>java.util.Collection</container-class>
<collection-property>true</collection-property>
</property-extension>
<property>
<property-name>id</property-name>
<property-class>string</property-class>
</property>
<property>
<property-name>icon</property-name>
<property-class>string</property-class>
</property>
<property>
<property-name>link</property-name>
<property-class>string</property-class>
</property>
<property>
<property-name>name</property-name>
<property-class>string</property-class>
</property>
<property>
<property-name>visible</property-name>
<property-class>boolean</property-class>
<property-extension>
<designer-extension>
<default-value>true</default-value>
<editor>com.ibm.std.Boolean</editor>
</designer-extension>
</property-extension>
</property>
<property>
<property-name>subMenu</property-name>
<property-class>java.util.List</property-class>
<property-extension>
<allow-run-time-binding>false</allow-run-time-binding>
<collection-property>true</collection-property>
<property-item-class>com.forte.complex.SubMenu</property-item-class>
<property-add-method>addSubMenu</property-add-method>
</property-extension>
</property>
<property>
<description>Target</description>
<display-name>Target</display-name>
<property-name>target</property-name>
<property-class>string</property-class>
<property-extension>
<designer-extension>
<editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
<editor-parameter>_blank
_self
_parent
_top
</editor-parameter>
</designer-extension>
</property-extension>
</property>
<complex-extension>
<tag-name>menu</tag-name>
</complex-extension>
</complex-type>
<complex-type>
<description>Sub Menu</description>
<display-name>Sub Menu</display-name>
<complex-id>com.forte.complex.submenu</complex-id>
<complex-class>com.forte.complex.SubMenu</complex-class>
<property-extension>
<container-class>java.util.Collection</container-class>
<collection-property>true</collection-property>
</property-extension>
<property>
<property-name>id</property-name>
<property-class>string</property-class>
</property>
<property>
<property-name>link</property-name>
<property-class>string</property-class>
</property>
<property>
<property-name>name</property-name>
<property-class>string</property-class>
</property>
<property>
<property-name>visible</property-name>
<property-class>boolean</property-class>
<property-extension>
<designer-extension>
<editor>com.ibm.std.Boolean</editor>
<default-value>true</default-value>
</designer-extension>
</property-extension>
</property>
<property>
<description>Target</description>
<display-name>Target</display-name>
<property-name>target</property-name>
<property-class>string</property-class>
<property-extension>
<designer-extension>
<editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
<editor-parameter>_blank
_self
_parent
_top
</editor-parameter>
</designer-extension>
</property-extension>
</property>
<complex-extension>
<tag-name>subMenu</tag-name>
</complex-extension>
</complex-type>
</faces-config>
您看过XPages扩展库中应用程序布局控件的源代码了吗?它几乎实现了这样一种结构,您可能会发现它实际上就是您所需要的。。我已经用复杂java文件中的addSubMenu方法解决了我的问题。您能给我一些建议吗?在哪里可以找到关于如何创建UI控件XPAGES的完整文档?比如如何将UI控件与eventHandler绑定,等等。我刚刚找到了一篇关于创建基本UI控件的文章,而这篇文章并没有解释如何与eventHandler绑定。添加您的解决方案作为问题的答案。因此,我们的生命来自回馈。请查看XPages书籍,它们涵盖了所有内容。同样,Extlib的来源也很有启发性,谢谢你的建议。我还在下面添加了我的解决方案