Fórumok
Retrieve multiple select selected values of the content programmitically
Raja Seth, módosítva 8 év-val korábban
Retrieve multiple select selected values of the content programmitically
Regular Member Bejegyzések: 233 Csatlakozás dátuma: 2011.08.18. Legújabb bejegyzések
Hi All,
I have a JournalArticle whose content xml is as given below. I have an element named "access_groups" which is of type multiselect in structure.
How could I get the selected list of options. For single value we normally use the below code :
and for repeatable we use the below code :
But in my case I don't have multiple dynamic-element. I have the hierarchy as
Please let me know how could I retrieve it.
Thanks & regards,
Raja
I have a JournalArticle whose content xml is as given below. I have an element named "access_groups" which is of type multiselect in structure.
"<!--?xml version="1.0"?-->
<root available-locales="en_US" default-locale="en_US">
<dynamic-element name="access_groups" type="list" index-type="keyword" index="0">
<dynamic-content language-id="en_US">
<option>26720</option>
<option>26726</option>
</dynamic-content>
</dynamic-element>
</root>"
How could I get the selected list of options. For single value we normally use the below code :
Node accessGroupNode = prodGroupContDocument.selectSingleNode("/root/dynamic-element/dynamic-content[@name='access_groups']/dynamic-content");
and for repeatable we use the below code :
List<node> accessGroupNodes = prodContDocument.selectNodes("/root/dynamic-element[@name='access_groups']/dynamic-content");</node>
But in my case I don't have multiple dynamic-element. I have the hierarchy as
root > dynamic-element > dynamic-content > option.
Please let me know how could I retrieve it.
Thanks & regards,
Raja
Raja Seth, módosítva 8 év-val korábban
RE: Retrieve multiple select selected values of the content programmiticall
Regular Member Bejegyzések: 233 Csatlakozás dátuma: 2011.08.18. Legújabb bejegyzések
There was issue with my node xpath. I need to use
and when I am selecting multiple values, its storing as :
For this I need to make a check if both the xpaths. Is there any fix for it?
"/root/dynamic-element[@name='access_groups']/dynamic-content/option. But there is a mismatch in the behavior of Liferay. If I am selecting single value, its storing as
<dynamic-element name="access_groups" type="list" index-type="keyword" index="0">
<dynamic-content language-id="en_US">26726</dynamic-content>
</dynamic-element>
and when I am selecting multiple values, its storing as :
<dynamic-element name="access_groups" type="list" index-type="keyword" index="0">
<dynamic-content language-id="en_US">
<option>26723</option>
<option>26726</option>
</dynamic-content>
</dynamic-element>
For this I need to make a check if both the xpaths. Is there any fix for it?