Hi all,
first let me describe what I want to achieve - afterwards I will
tell you about the problem I have ;) Perhaps that's merely a
Java question but I don't know where to ask instead/wasn't able
to find something on the net.
I want to create a "AdminPanel" component displayed only when the
admin user is logged in and showing further information
about the database record currently displayed in a "RecordDetails"
page (like id, version etc.).
The component shall be included like this in the "RecordDetails" page:
<span jwcid="@ShowAdminPanel" source="ognl:record" properties="id:id,
version:version"/>
"source" is the object to consider
"properties" the object's database fields to display
I've created a component template (as the panel shall be displayed in a
nice box) and as the length of the list of properties is not fixed
I had the idea to use a generic For component inside this template to
iterate through an array of all the properties.
<span jwcid="@For" source="ognl:attributes" value="ognl:attribute">
<tr>
<td>
<span key="ognl:attribute.key">attribute.key</span>
</td>
<td></td>
</tr>
<tr>
<td><span jwcid="@Insert" value="ognl:attribute.value"/></td>
<td></td>
</tr>
</span>
I'm using the renderComponent() method to parse the properties and
create the array the For component can read as its "source" parameter.
---
if (isParameterBound("properties") && isParameterBound("source"))
{
String properties = getProperties();
final Object object = getSource();
String[] parts = properties.split(",");
Map attributes = new HashMap();
Object value = null;
for (String part : parts)
{
part.trim();
String[] key = part.split(":");
try
{
value = Ognl.getValue(key[0], object);
} catch (OgnlException ex)
{}
attributes.put(key[1], value);
}
setAttributes(attributes);
}
super.renderComponent(writer, cycle);
---
But how can I access the entries of the array without actually knowing
which "keys" (that is properties) exist? The above doesn't work :(
Thanks!
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]