Hi.
I have implemented a dynamically-generated dropdown list, called a
ListMenuDropDown component and i've used an html template to define the
rendering for the component. This component is backed by a MenuManager, which
makes calls to a mySQL db to generate the descriptions for each MenuItem. A
MenuItem contains a method, MenuItem.getAction() that is parsed when a
particular MenuItem is clicked.
I chose to use a DirectLink within the html portion of the template, to
facilitate a naming convention for each MenuItem.getAction(). Based on this
decision, i then used a listener method, itemClicked() to parse the
Menu.getAction() and determine which page to then render.
My goal is to activate a page that implements the IExternalPage interface from
this itemClicked() method. I worked out the code (see below), but i'm wondering
if someone can comment on whether this is a legitimate use of the
activateExternalPage(Object[], IRequestCycle) method?
My other option was to encode ILinks using the ExternalService and have the
component control its rendering sans the html template. I realize now such an
approach might have been a better solution than what i am presenting, but am
curious as to why one would favor such a construction over the programmatic
solution listed below?
public void itemSelected(IRequestCycle cycle) {
IPage page = parsePage( cycle );
Object[] params = parsePageParams( cycle );
log.debug("itemSelected():params="+ params.toString());
if(page instanceof IExternalPage){
IExternalPage epage = (IExternalPage)page;
epage.activateExternalPage(params, cycle);
}else{
cycle.setServiceParameters(params);
}
//redirect to the page
cycle.activate( page );
}
A portion of my html template looks like this:
<div>
<ul id="nav">
<span jwcid="@Foreach" source="ognl:menu.menuItems" value="ognl:menuItemI">
<li>
<a jwcid="@DirectLink" listener="ognl:listeners.itemSelected"
parameters="ognl:menuItemI.action">
<span jwcid="@Insert" value="ognl:menuItemI.heading"/>
</a>
</li>
</ul>
</div>
...
thanks for the thoughts+criticism. this is a killer framework.
-rob
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]