Using multi-value properties in JSP components


i trying figure out if doing small step wrong or if don't have full grasp on how things work.

 

i accessing multi-value property jsp of component:

 

<%@include file="/libs/foundation/global.jsp" %>

    <h2>keys</h2>

    <div class="container_16">

        <div class="grid_8"><%

object keysobj = properties.get("keys");

if (keysobj != null)

{

string[] keys = (string[]) keysobj;

%>

<%= keys %><%

} %></div>

</div>

 

here how defined component:

 

{

     "jcr:createdby":"admin",

     "jcr:title":"my listing",

     "allowedparents":["*/*parsys"],

     "componentgroup":"listing group",

     "sling:resourcesupertype":"foundation/components/parbase",

     "jcr:created":"wed aug 15 2012 20:01:15 gmt-0400",

     "jcr:primarytype":"cq:component",

     "keys":[""]

}

 

so keys multi-value string object. supposing value string[].

 

i created dialog set values within cq page edit.

 

- mylist

--- dialog [cq:dialog]

----- items [cq:widget]

------- items [cq:widgetcollection]

--------- tabs1 [cq:panel]

----------- items [cq:widgetcollection]

------------- keys [cq:widget]

 

the keys cq:widget defined as:

 

{

     "fieldlabel":"keys list",

     "xtype":"multifield",

     "name":"./keys",

     "jcr:primarytype":"cq:widget",

     "fielddescription":"list keys display"

}

 

i placed component existing geometrixx page test. when double-clicked on able add multiple values.

 

it failing when attempt coerce properties.get method string[]: string[] keys = (string[]) keysobj;

 

16.08.2012 11:58:29.444 *error* [10.176.196.66 [1345132705084] /content/geometrixx/en/services.html http/1.1] com.day.cq.wcm.core.impl.wcmdebugfilter error during include of slingrequestpathinfo: path='/content/geometrixx/en/services/jcr:content/par/keylist', selectorstring='null', extension='html', suffix='null' org.apache.sling.api.scripting.scriptevaluationexception: exception occurred processing jsp page /apps/mylist/components/keylist/keylist.jsp @ line 14

<snip stack trace>

caused by: java.lang.classcastexception: [ljava.lang.object; cannot cast [ljava.lang.string;

 

so leads question.

 

it looks wrong on how coerce results of properties.get string[]. best way work multi-value properties? want iterate through values in multi-value property.

 

should have specified index in method?

---- properties.get("keys[0]");

 

thanks!

did try

 

string[] properties = properties.get("<your multivalue properties>"",string[].class);

 

 

?

 

for(string eachproperty:properties){

-- eachproperty

}

 

yogesh



More discussions in Archived Spaces


adobe

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support