我已经创建了一个具有对话框的组件。该对话框有一个选项卡,其中有一个下拉列表。在下拉列表中选择的值打开一个新的选项卡。它与OOTB列表组件略有不同,因为在下拉列表中更改值不会关闭先前打开的选项卡。这意味着每当从下拉列表中选择一个新值时,就会打开一个新的选项卡,并且它不会覆盖任何其他选项卡。我已经取得了很大成就。这就是我面临的问题:当我填写所有选项卡中的值,然后保存并关闭对话框,然后重新打开它,我只能看到一个选项卡,这是最后一个通过下拉打开的选项卡。
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Dialog"
height="{Long}400"
manageTabs="function(tab,noSwitch){var tabs=['list','plansbenefits','claimsbalances','prescriptions','findpricecare','healthwellness','customerservice','chat','related'];var index=tabs.indexOf(tab);if(index==-1) return;for(var i=1;i<tabs.length;i++){if(index==i){this.unhideTabStripItem(i);}}this.doLayout();if(!noSwitch)this.activate(index);}"
title="Sub-Footer"
width="{Long}700"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
<list
jcr:primaryType="cq:Widget"
title="Footer Properties"
xtype="panel">
<items jcr:primaryType="cq:WidgetCollection">
<optionsFrom
jcr:primaryType="cq:Widget"
defaultValue=""
fieldLabel="Choose from the options"
name="./optionsFrom"
type="select"
xtype="selection">
<listeners
jcr:primaryType="nt:unstructured"
loadcontent="function(){this.findParentByType('tabpanel').manageTabs(this.getValue(),true);}"
selectionchanged="function(box,value){box.findParentByType('tabpanel').manageTabs(value);}"/>
<options jcr:primaryType="cq:WidgetCollection">
<plansbenefits
jcr:primaryType="nt:unstructured"
text="Plans & Benefits"
value="plansbenefits"/>
<claimsbalances
jcr:primaryType="nt:unstructured"
text="Claims & Balances"
value="claimsbalances"/>
<prescriptions
jcr:primaryType="nt:unstructured"
text="Prescriptions"
value="prescriptions"/>
<findpricecare
jcr:primaryType="nt:unstructured"
text="Find & Price Care"
value="findpricecare"/>
<healthwellness
jcr:primaryType="nt:unstructured"
text="Health & Wellness"
value="healthwellness"/>
<customerservice
jcr:primaryType="nt:unstructured"
text="Customer Service"
value="customerservice"/>
<chat
jcr:primaryType="nt:unstructured"
text="Chat"
value="chat"/>
<related
jcr:primaryType="nt:unstructured"
text="Related"
value="related"/>
</options>
</optionsFrom>
</items>
</list>
<plansbenefits
jcr:primaryType="cq:Widget"
title="Plans & Benefits"
xtype="panel">
<listeners
jcr:primaryType="nt:unstructured"
render="function() { this.findParentByType('tabpanel').hideTabStripItem(1); }"/>
<items jcr:primaryType="cq:WidgetCollection">
<title
jcr:primaryType="cq:Widget"
defaultValue="Plans & Benefits"
emptyText="Plans & Benefits"
fieldLabel="Title"
name="./title"
xtype="textfield"/>
<topics
jcr:primaryType="cq:Widget"
fieldDescription="Press + to add more topics"
fieldLabel="Configure Topics"
name="./topicsplansandbenefits"
width="1000"
xtype="multifield">
<fieldConfig
jcr:primaryType="cq:Widget"
name="./fieldConfig"
xtype="multifieldpanel">
<items jcr:primaryType="cq:WidgetCollection">
<topic
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the title for the topic"
fieldLabel="Topic Title"
key="topic"
width="600"
xtype="pathfield"/>
<url
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the URL for the topic"
fieldLabel="Topic URL"
key="url"
rootPath="/content/xxxxx"
width="600"
xtype="pathfield"/>
<check
jcr:primaryType="cq:Widget"
fieldLabel="Is External?"
key="check"
xtype="checkbox"/>
</items>
</fieldConfig>
</topics>
</items>
</plansbenefits>
<claimsbalances
jcr:primaryType="cq:Widget"
title="Claims & Balances"
xtype="panel">
<listeners
jcr:primaryType="nt:unstructured"
render="function() { this.findParentByType('tabpanel').hideTabStripItem(2); }"/>
<items jcr:primaryType="cq:WidgetCollection">
<title
jcr:primaryType="cq:Widget"
defaultValue="Claims & Balances"
emptyText="Claims & Balances"
fieldLabel="Title"
name="./title"
xtype="textfield"/>
<topics
jcr:primaryType="cq:Widget"
fieldDescription="Press + to add more topics"
fieldLabel="Configure Topics"
name="./topicsclaimsbalances"
width="1000"
xtype="multifield">
<fieldConfig
jcr:primaryType="cq:Widget"
name="./fieldConfig"
xtype="multifieldpanel">
<items jcr:primaryType="cq:WidgetCollection">
<topic
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the title for the topic"
fieldLabel="Topic Title"
key="topic"
width="600"
xtype="pathfield"/>
<url
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the URL for the topic"
fieldLabel="Topic URL"
key="url"
rootPath="/content/xxxxx"
width="600"
xtype="pathfield"/>
<check
jcr:primaryType="cq:Widget"
fieldLabel="Is External?"
key="check"
xtype="checkbox"/>
</items>
</fieldConfig>
</topics>
</items>
</claimsbalances>
<prescriptions
jcr:primaryType="cq:Widget"
title="Prescriptions"
xtype="panel">
<listeners
jcr:primaryType="nt:unstructured"
render="function() { this.findParentByType('tabpanel').hideTabStripItem(3); }"/>
<items jcr:primaryType="cq:WidgetCollection">
<title
jcr:primaryType="cq:Widget"
defaultValue="Prescriptions"
emptyText="Prescriptions"
fieldLabel="Title"
name="./title"
xtype="textfield"/>
<topics
jcr:primaryType="cq:Widget"
fieldDescription="Press + to add more topics"
fieldLabel="Configure Topics"
name="./topicsprescriptions"
width="1000"
xtype="multifield">
<fieldConfig
jcr:primaryType="cq:Widget"
name="./fieldConfig"
xtype="multifieldpanel">
<items jcr:primaryType="cq:WidgetCollection">
<topic
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the title for the topic"
fieldLabel="Topic Title"
key="topic"
width="600"
xtype="pathfield"/>
<url
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the URL for the topic"
fieldLabel="Topic URL"
key="url"
rootPath="/content/xxxxx"
width="600"
xtype="pathfield"/>
<check
jcr:primaryType="cq:Widget"
fieldLabel="Is External?"
key="check"
xtype="checkbox"/>
</items>
</fieldConfig>
</topics>
</items>
</prescriptions>
<findpricecare
jcr:primaryType="cq:Widget"
title="Find & Price Care"
xtype="panel">
<listeners
jcr:primaryType="nt:unstructured"
render="function() { this.findParentByType('tabpanel').hideTabStripItem(4); }"/>
<items jcr:primaryType="cq:WidgetCollection">
<title
jcr:primaryType="cq:Widget"
defaultValue="Find & Price Care"
emptyText="Find & Price Care"
fieldLabel="Title"
name="./title"
xtype="textfield"/>
<topics
jcr:primaryType="cq:Widget"
fieldDescription="Press + to add more topics"
fieldLabel="Configure Topics"
name="./topicsfindpricecare"
width="1000"
xtype="multifield">
<fieldConfig
jcr:primaryType="cq:Widget"
name="./fieldConfig"
xtype="multifieldpanel">
<items jcr:primaryType="cq:WidgetCollection">
<topic
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the title for the topic"
fieldLabel="Topic Title"
key="topic"
width="600"
xtype="pathfield"/>
<url
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the URL for the topic"
fieldLabel="Topic URL"
key="url"
rootPath="/content/xxxxx"
width="600"
xtype="pathfield"/>
<check
jcr:primaryType="cq:Widget"
fieldLabel="Is External?"
key="check"
xtype="checkbox"/>
</items>
</fieldConfig>
</topics>
</items>
</findpricecare>
<healthwellness
jcr:primaryType="cq:Widget"
title="Health & Wellness"
xtype="panel">
<listeners
jcr:primaryType="nt:unstructured"
render="function() { this.findParentByType('tabpanel').hideTabStripItem(5); }"/>
<items jcr:primaryType="cq:WidgetCollection">
<title
jcr:primaryType="cq:Widget"
defaultValue="Health & Wellness"
emptyText="Health & Wellness"
fieldLabel="Title"
name="./title"
xtype="textfield"/>
<topics
jcr:primaryType="cq:Widget"
fieldDescription="Press + to add more topics"
fieldLabel="Configure Topics"
name="./topics"
width="1000"
xtype="multifield">
<fieldConfig
jcr:primaryType="cq:Widget"
name="./fieldConfig"
xtype="multifieldpanel">
<items jcr:primaryType="cq:WidgetCollection">
<topic
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the title for the topic"
fieldLabel="Topic Title"
key="topic"
width="600"
xtype="pathfield"/>
<url
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the URL for the topic"
fieldLabel="Topic URL"
key="url"
rootPath="/content/xxxxx"
width="600"
xtype="pathfield"/>
<check
jcr:primaryType="cq:Widget"
fieldLabel="Is External?"
key="check"
xtype="checkbox"/>
</items>
</fieldConfig>
</topics>
</items>
</healthwellness>
<customerservice
jcr:primaryType="cq:Widget"
title="Customer Service"
xtype="panel">
<listeners
jcr:primaryType="nt:unstructured"
render="function() { this.findParentByType('tabpanel').hideTabStripItem(6); }"/>
<items jcr:primaryType="cq:WidgetCollection">
<title
jcr:primaryType="cq:Widget"
defaultValue="Customer Service"
emptyText="Customer Service"
fieldLabel="Title"
name="./title"
xtype="textfield"/>
<topics
jcr:primaryType="cq:Widget"
fieldDescription="Press + to add more topics"
fieldLabel="Configure Topics"
name="./topicscustomerservice"
width="1000"
xtype="multifield">
<fieldConfig
jcr:primaryType="cq:Widget"
name="./fieldConfig"
xtype="multifieldpanel">
<items jcr:primaryType="cq:WidgetCollection">
<topic
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the title for the topic"
fieldLabel="Topic Title"
key="topic"
width="600"
xtype="pathfield"/>
<url
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the URL for the topic"
fieldLabel="Topic URL"
key="url"
rootPath="/content/xxxxx"
width="600"
xtype="pathfield"/>
<check
jcr:primaryType="cq:Widget"
fieldLabel="Is External?"
key="check"
xtype="checkbox"/>
</items>
</fieldConfig>
</topics>
</items>
</customerservice>
<chat
jcr:primaryType="cq:Widget"
title="Chat"
xtype="panel">
<listeners
jcr:primaryType="nt:unstructured"
render="function() { this.findParentByType('tabpanel').hideTabStripItem(7); }"/>
<items jcr:primaryType="cq:WidgetCollection">
<title
jcr:primaryType="cq:Widget"
defaultValue="Chat"
emptyText="Chat"
fieldLabel="Title"
name="./title"
xtype="textfield"/>
<topics
jcr:primaryType="cq:Widget"
fieldDescription="Press + to add more topics"
fieldLabel="Configure Topics"
name="./topicschat"
width="1000"
xtype="multifield">
<fieldConfig
jcr:primaryType="cq:Widget"
name="./fieldConfig"
xtype="multifieldpanel">
<items jcr:primaryType="cq:WidgetCollection">
<topic
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the title for the topic"
fieldLabel="Topic Title"
key="topic"
width="600"
xtype="pathfield"/>
<url
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the URL for the topic"
fieldLabel="Topic URL"
key="url"
rootPath="/content/xxxxx"
width="600"
xtype="pathfield"/>
<check
jcr:primaryType="cq:Widget"
fieldLabel="Is External?"
key="check"
xtype="checkbox"/>
</items>
</fieldConfig>
</topics>
</items>
</chat>
<related
jcr:primaryType="cq:Widget"
title="Related"
xtype="panel">
<listeners
jcr:primaryType="nt:unstructured"
render="function() { this.findParentByType('tabpanel').hideTabStripItem(8); }"/>
<items jcr:primaryType="cq:WidgetCollection">
<title
jcr:primaryType="cq:Widget"
defaultValue="Related"
emptyText="Related"
fieldLabel="Title"
name="./title"
xtype="textfield"/>
<topics
jcr:primaryType="cq:Widget"
fieldDescription="Press + to add more topics"
fieldLabel="Configure Topics"
name="./topicsrelated"
width="1000"
xtype="multifield">
<fieldConfig
jcr:primaryType="cq:Widget"
name="./fieldConfig"
xtype="multifieldpanel">
<items jcr:primaryType="cq:WidgetCollection">
<topic
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the title for the topic"
fieldLabel="Topic Title"
key="topic"
width="600"
xtype="pathfield"/>
<url
jcr:primaryType="cq:Widget"
fieldDescription="Please enter the URL for the topic"
fieldLabel="Topic URL"
key="url"
rootPath="/content/xxxxx"
width="600"
xtype="pathfield"/>
<check
jcr:primaryType="cq:Widget"
fieldLabel="Is External?"
key="check"
xtype="checkbox"/>
</items>
</fieldConfig>
</topics>
</items>
</related>
</items>
</jcr:root>
下面是用例:
1)打开组件的对话框。
2)从第一个选项卡上的下拉列表中选择一个值。一个新的标签将会打开。叫它标签A.作者。
3)从第一个选项卡上的下拉列表中选择另一个值。另一个标签会打开。把它叫做制表符。
4)保存并关闭对话框
5)重新打开对话框。
您将看到只有选项卡B是可见的。理想情况下,选项卡A和选项卡B都应该是可见的。
提前感谢
发布于 2015-08-03 13:32:52
查看上面的代码示例,在optionsFrom节点加载内容侦听器中注册的回调函数将只显示一个选项卡,因为(大概) optionsFrom属性中只存储了一个值。为了提供您要寻找的行为,加载内容侦听器调用的函数可以查看节点存储库,以确定哪些选项卡存储了针对它们的数据,然后才决定是分别显示还是隐藏每个选项卡。
https://stackoverflow.com/questions/30517787
复制相似问题