You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Gooch, Allen" <go...@darden.virginia.edu> on 2004/02/24 20:33:09 UTC
Component state and DirectLink
I am currently working on a MenuBar component which binds a model like
so:
<component-specification class="common.tapestry.menubar.MenuBar"
allow-body="yes" allow-informal-parameters="yes">
<parameter name="model"
type="common.tapestry.menubar.IMenuModel" direction="in"
required="yes"/>
</component-specification>
This menubar component renders each of its menu items as a DirectLink
with a MenuBar listener method bound with the indices to selected item
passed in as params.
In my MenuBar.selectItem() listener method:
Class MenuBar extends BaseComponent {
...
public void selectMenu(IRequestCycle cycle) {
Object[] params = cycle.getServiceParameters();
Integer menuItem = (Integer) params[0];
Integer submenuItem = (Integer) params[1];
select(menuItem.intValue(), submenuItem.intValue());
String page = null;
if (getSelectedSubmenuIndex() == 0) {
page =
getModel().getMenu()[getSelectedMenuIndex()].getPage(); // getModel()
returns null!!
} else {
page =
getModel().getMenu()[getSelectedMenuIndex()].getSubmenu()[getSelectedSub
menuIndex()].getPage();
}
cycle.activate(page);
}
The problem is that the bound model parameter is not available from
within my DirectLink listener method. What is the Tapestry-recommended
way of doing this?
Many thanks...
-allen
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Component state and DirectLink
Posted by Programozás <pr...@hotmail.com>.
As I know you should use direction="auto".
See the docs about it.
Norbi
----- Original Message -----
From: "Gooch, Allen" <go...@darden.virginia.edu>
To: <ta...@jakarta.apache.org>
Sent: Tuesday, February 24, 2004 8:33 PM
Subject: Component state and DirectLink
I am currently working on a MenuBar component which binds a model like
so:
<component-specification class="common.tapestry.menubar.MenuBar"
allow-body="yes" allow-informal-parameters="yes">
<parameter name="model"
type="common.tapestry.menubar.IMenuModel" direction="in"
required="yes"/>
</component-specification>
This menubar component renders each of its menu items as a DirectLink
with a MenuBar listener method bound with the indices to selected item
passed in as params.
In my MenuBar.selectItem() listener method:
Class MenuBar extends BaseComponent {
..
public void selectMenu(IRequestCycle cycle) {
Object[] params = cycle.getServiceParameters();
Integer menuItem = (Integer) params[0];
Integer submenuItem = (Integer) params[1];
select(menuItem.intValue(), submenuItem.intValue());
String page = null;
if (getSelectedSubmenuIndex() == 0) {
page =
getModel().getMenu()[getSelectedMenuIndex()].getPage(); // getModel()
returns null!!
} else {
page =
getModel().getMenu()[getSelectedMenuIndex()].getSubmenu()[getSelectedSub
menuIndex()].getPage();
}
cycle.activate(page);
}
The problem is that the bound model parameter is not available from
within my DirectLink listener method. What is the Tapestry-recommended
way of doing this?
Many thanks...
-allen
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: Component state and DirectLink
Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
Use direction="auto" for any parameters that must be accessed from within a listener method.
--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components
http://howardlewisship.com
> -----Original Message-----
> From: Gooch, Allen [mailto:goocha@darden.virginia.edu]
> Sent: Tuesday, February 24, 2004 2:33 PM
> To: tapestry-user@jakarta.apache.org
> Subject: Component state and DirectLink
>
>
> I am currently working on a MenuBar component which binds a model like
> so:
>
> <component-specification class="common.tapestry.menubar.MenuBar"
> allow-body="yes" allow-informal-parameters="yes">
>
> <parameter name="model"
> type="common.tapestry.menubar.IMenuModel" direction="in"
> required="yes"/>
>
> </component-specification>
>
>
> This menubar component renders each of its menu items as a DirectLink
> with a MenuBar listener method bound with the indices to selected item
> passed in as params.
>
> In my MenuBar.selectItem() listener method:
>
> Class MenuBar extends BaseComponent {
> ...
> public void selectMenu(IRequestCycle cycle) {
> Object[] params = cycle.getServiceParameters();
> Integer menuItem = (Integer) params[0];
> Integer submenuItem = (Integer) params[1];
>
> select(menuItem.intValue(), submenuItem.intValue());
> String page = null;
> if (getSelectedSubmenuIndex() == 0) {
> page =
> getModel().getMenu()[getSelectedMenuIndex()].getPage(); // getModel()
> returns null!!
> } else {
> page =
> getModel().getMenu()[getSelectedMenuIndex()].getSubmenu()[getS
> electedSub
> menuIndex()].getPage();
> }
> cycle.activate(page);
> }
>
> The problem is that the bound model parameter is not available from
> within my DirectLink listener method. What is the
> Tapestry-recommended
> way of doing this?
>
> Many thanks...
> -allen
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org