在设计定义中获取分组属性[已使用代码更新]

时间:2017-03-30 21:25:21

标签: xpages

如何在自定义控件属性中访问组的属性?

我的自定义控件有一个名为" headerSettings"并且该组中有两个属性," panelTitle"和" panelTitleType"。

在我的设计定义中,我一直使用此语法来获取值

 Panel title = <%=this.headerSettings.panelTitle%>

基本上就是this.property。

对于团体我尝试了似乎合理的事情

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
     xmlns:xc="http://www.ibm.com/xsp/custom"
     xmlns:xe="http://www.ibm.com/xsp/coreex">    
<xp:table style="width:100%;border-style:solid;border-width:thin;border-color:rgb(66,139,202)"
    cellpadding="0"
    cellspacing="0">
    <xp:tr style="width:100%;background-color:rgb(66,139,202)">
            <xp:td> 


**Panel title = <%=this.headerSettings.panelTitle%>**

<%var pnlLay=this.panelLayout%>
Panel title = <%=this.panelLayout%>
<% if(pnlLay==='header'){ %>
TEXT
<%}%>

但是得到了错误&#34; headerSettings&#34;是null,它不是。

尝试了其他事情并用Google搜索但没有运气。

[开始更新]

好的,请在下面找到我得到的错误代码和设计定义的代码。

enter image description here

<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
  <faces-config-extension>
    <namespace-uri>http://www.ibm.com/xsp/custom</namespace-uri>
    <default-prefix>xc</default-prefix>
  </faces-config-extension>
  <composite-component>
    <component-type>cc_CommonPanel</component-type>
    <composite-name>cc_CommonPanel</composite-name>
    <composite-file>/cc_CommonPanel.xsp</composite-file>
    <composite-extension>
      <designer-extension>
        <in-palette>true</in-palette>
        <render-markup>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&#xd;
&lt;xp:view xmlns:xp="http://www.ibm.com/xsp/core"&#xd;
     xmlns:xc="http://www.ibm.com/xsp/custom"&#xd;
     xmlns:xe="http://www.ibm.com/xsp/coreex"&gt;&#xd;
&#xd;
&lt;xp:table style="width:100%;border-style:solid;border-width:thin;border-color:rgb(66,139,202)"&#xd;
    cellpadding="0"&#xd;
    cellspacing="0"&gt;&#xd;
&#xd;
&lt;xp:tr style="width:100%;background-color:rgb(66,139,202)"&gt;           &#xd;
&lt;xp:td&gt;&#xd;
&lt;% if(this.panelTitle=='') { %&gt;&#xd;
Panel Title:NONE&#xd;
&lt;% } else { %&gt;&#xd;
&lt;xp:span style="font-weight:bold;color:white"&gt;&#xd;
&lt;%=this.panelTitle%&gt;&#xd;
&lt;/xp:span&gt;&#xd;
&lt;%}%&gt;&#xd;
&lt;/xp:td&gt;&#xd;
&lt;/xp:tr&gt;&#xd;
&lt;xp:tr&gt;&#xd;
&lt;/xp:tr&gt;&#xd;
&#xd;
            &lt;%var cnt=this.panelNumFacets%&gt;&#xd;
                &lt;%for (var x=1;x&lt;=cnt;x++){%&gt;&#xd;
                &lt;xp:tr&gt;&#xd;
                &lt;xp:td&gt;               &#xd;
                &lt;xp:div styleClass="row" style="padding-right:15.0px"&gt;&#xd;
                    &lt;xp:callback&#xd;
                        &lt;%="id="%&gt;&lt;%='"pnlCallBack'+x+'"'%&gt;&#xd;
                        &lt;%="facetName="%&gt;&lt;%='"pnlContentFacet'+x+'"&gt;'%&gt;&#xd;
                        &lt;%="xp:key="%&gt;&lt;%='"pnlContentFacet'+x+'"&gt;'%&gt;&gt; &#xd;
                    &lt;/xp:callback&gt;            &#xd;
                &lt;/xp:div&gt;&#xd;
                &lt;/xp:td&gt;&#xd;
                &lt;/xp:tr&gt;              &#xd;
                &lt;%}%&gt;     &#xd;
&lt;xp:tr&gt;&#xd;
&lt;/xp:tr&gt;&#xd;
&#xd;
&#xd;
&#xd;
&lt;xp:tr style="width:100%;background-color:rgb(66,139,202)"&gt;           &#xd;
&lt;xp:td&gt;&#xd;
&lt;% if(this.panelTitle=='') { %&gt;&#xd;
Panel Title:NONE&#xd;
&lt;% } else { %&gt;&#xd;
&lt;xp:span style="font-weight:bold;color:white"&gt;&#xd;
&lt;%=this.panelTitle%&gt;&#xd;
&lt;/xp:span&gt;&#xd;
&lt;%}%&gt;&#xd;
&lt;/xp:td&gt;&#xd;
&lt;/xp:tr&gt;&#xd;
&#xd;
&#xd;
&lt;/xp:table&gt;&#xd;
&#xd;
&lt;/xp:view&gt;</render-markup>
      </designer-extension>
    </composite-extension>
    <property>
      <property-name>panelID</property-name>
      <property-class>string</property-class>
      <description>ID of the panel. &#xd;
&#xd;
This is necessary if you want to animate the panel with JQuery</description>
      <property-extension>
        <required>true</required>
      </property-extension>
    </property>
    <property>
      <property-name>panelLayout</property-name>
      <property-class>string</property-class>
      <property-extension>
        <required>true</required>
        <designer-extension>
          <editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
          <editor-parameter>header&#xd;
footer&#xd;
both&#xd;
none</editor-parameter>
          <default-value>header</default-value>
        </designer-extension>
      </property-extension>
      <description>Select the layout of your panel. Display a panel with:&#xd;
&#xd;
– a Header&#xd;
– a Footer&#xd;
– both&#xd;
&#xd;
– none (only panel body will be displayed)&#xd;
&#xd;
Default value is none</description>
    </property>
    <property>
      <property-name>panelStateClass</property-name>
      <property-class>string</property-class>
      <property-extension>
        <designer-extension>
          <editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
          <editor-parameter>panel-default&#xd;
panel-primary&#xd;
panel-success&#xd;
panel-info&#xd;
panel-warning&#xd;
panel-danger</editor-parameter>
          <default-value>panel-primary</default-value>
        </designer-extension>
        <required>true</required>
      </property-extension>
      <description>Make a panel more meaningful to a particular context by adding any of the contextual state classes.&#xd;
&#xd;
Default: panel-default</description>
    </property>
    <property-type>
      <property-name>headerSettings</property-name>
      <property>
        <property-name>panelTitle</property-name>
        <property-class>string</property-class>
        <description>Enter text to be displayed as the panel’s title</description>
      </property>
      <property-extension>
        <designer-extension>
          <visible>panelLayout == "header" || panelLayout == "both";</visible>
        </designer-extension>
      </property-extension>
      <property>
        <property-name>panelTitleType</property-name>
        <property-class>string</property-class>
        <property-extension>
          <designer-extension>
            <editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
            <editor-parameter>h1&#xd;
h2&#xd;
h3&#xd;
h4&#xd;
h5&#xd;
h6&#xd;
plain</editor-parameter>
            <default-value>plain</default-value>
          </designer-extension>
        </property-extension>
        <description>Select how the panel title is going to be rendered. &#xd;
You can select h-tags (h1-h6) or none to display plain text.&#xd;
Default is plain</description>
      </property>
    </property-type>
    <property>
      <property-name>panelHide</property-name>
      <property-class>string</property-class>
      <property-extension>
        <designer-extension>
          <editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
          <editor-parameter>no&#xd;
yes</editor-parameter>
          <default-value>no</default-value>
        </designer-extension>
      </property-extension>
      <description>Select “yes”, if the panel should be hidden initially&#xd;
&#xd;
Default value is no</description>
    </property>
    <property>
      <property-name>panelHeightFixed</property-name>
      <property-class>string</property-class>
      <description>Select “yes”, if you want the panel’s height to be fixed. If you select “no”, the panel will expaned based on the content, until it reaches the height set in panelHeightMax.&#xd;
&#xd;
Any setting for this property will be ignored, if panelHeightMax is not set.&#xd;
&#xd;
Default: no</description>
      <property-extension>
        <designer-extension>
          <editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
          <editor-parameter>no&#xd;
yes</editor-parameter>
          <default-value>no</default-value>
        </designer-extension>
      </property-extension>
    </property>
    <property>
      <property-name>panelHeightMax</property-name>
      <property-class>string</property-class>
      <description>Enter the maximum height of the panel.&#xd;
&#xd;
Leave blank, if you don”t want a maximum height.&#xd;
&#xd;
Note: If you enter a maximum height and there is a possibility that the content of the panel overflows, make sure you set panelEnableScroll to “yes”</description>
    </property>
    <property>
      <property-name>panelEnableScroll</property-name>
      <property-class>string</property-class>
      <description>Set to “yes”, if you”ve defined a maximum height and there is a possibility for the content to overflow.&#xd;
Any setting for this property will be ignored, if panelHeightMax is not set.&#xd;
&#xd;
Default: no</description>
      <property-extension>
        <designer-extension>
          <editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
          <editor-parameter>no&#xd;
yes</editor-parameter>
          <default-value>no</default-value>
        </designer-extension>
      </property-extension>
    </property>
    <property>
      <property-name>panelNumFacets</property-name>
      <property-class>int</property-class>
      <display-name>Number of Facets in Content</display-name>
      <property-extension>
        <designer-extension>
          <editor>com.ibm.std.Integer</editor>
          <default-value>1</default-value>
        </designer-extension>
      </property-extension>
    </property>
    <property>
      <property-name>panelTitle</property-name>
      <property-class>string</property-class>
      <display-name>The Title of the Panel</display-name>
    </property>
    <property>
      <property-name>panelTitleType</property-name>
      <property-class>string</property-class>
      <display-name>The type of panel</display-name>
      <property-extension>
        <designer-extension>
          <editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
          <editor-parameter>h1&#xd;
h2&#xd;
h3&#xd;
h4&#xd;
h5&#xd;
h6&#xd;
plain</editor-parameter>
          <default-value>plain</default-value>
        </designer-extension>
      </property-extension>
      <description>Select how the panel title is going to be rendered. &#xd;
You can select h-tags (h1-h6) or none to display plain text.&#xd;
Default is plain</description>
    </property>
  </composite-component>
</faces-config>

                

[更新了更多代码 - 来自cc_CommonPanel.xsp-config]

struct BTreeNode {
    bool is_leaf=true;
    std::vector<int> elements;
    std::vector<BTreeNode*> children;
    BTreeNode() {}
    BTreeNode (std::vector<int> v) {
    this->elements = v;
    }
};

void traverse(BTreeNode* root) {
  for(int i = 0; i < (int)root->children.size(); ++i){
    traverse(root->children[i]);
    cout << root->elements[i] << endl;
  }
  traverse(root->children[root->children.size() -1]);
}

0 个答案:

没有答案