-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Using the context attribute is the way to go. It's plain 'context' and
not 't:context', though.
The context must be a primitive (or encoded as a primitive), so I
would recommend you start by passing only the position
value="videoItem.position"
There is another thing you need to do though which is related to the
inner workings of Tapestry's Loop component. If the Submit is inside a
loop, you must also add
defer="false"
to the Submit component (see Javadoc of Submit)
So you have something like
<input t:type="submit" t:id="topLevel" context="videoItem.position"
defer="false" t:value="${videoItem.name}" />
Then Tapestry passes the position parameter (the context in the above
input component) to every call of onSelectedFromTopLevel:
public void onSelectedFromTopLevel(int position) {
....
}
Hope this helps
- - Arno
Am 15.05.2012 11:36, schrieb karthi:
> Hi,
>
> In UI I need to display 5 (for eg.,) names (submittable items) in
> vertical order
>
> Animation Education Music Solutions Tech
>
> with a title in the top "Videos"
>
> I have designed this part when the user clicks on the Animation,
> need to change the title as Videos/Animation and need to expand the
> Animation to next extent like a tree
>
>
> Animation Arts Cartoons Education Music Solutions Tech
>
> <t:zone t:id="videoZone" id="videoZone" t:update="highlight">
> <t:form t:id="videoForm" zone="videoZone">
>
> <p class="topmenu">${title}</p>
>
> <t:loop source="videoDatas" encoder="encoder" value="videoItem">
> <br /> <table width="100%" cellpadding="2" cellspacing="0"> <tr>
> <td width="100%"> <div id="navi"> <input t:type="submit"
> t:id="topLevel" t:value="${videoItem.name}" /> </div> </td> </tr>
> </table> <br /> </t:loop>
>
> </t:form> </t:zone>
>
> Index.java code:
>
> public class Index {
>
> @SuppressWarnings("unused") @Property private CommItem videoItem;
>
> @Persist private List<CommItem> videoItems;
>
> @InjectComponent private Zone videoZone;
>
> public List<CommItem> getVideoDatas() { videoItems = new
> ArrayList<CommItem>(); // levelOneItems contains those 5 items
> "Animation", "Education" ... for(int index = 0; index <
> levelOneItems.length; index++) { CommItem item = new CommItem();
> item.setPosition(index); item.setName(levelOneItems[index]);
> videoItems.add(item); } return videoItems; }
>
> void onSelectedFromTopLevel() { System.out.println("Selected button
> items is --> "); }
>
> Object onActionFromNewsForm() { return videoZone.getBody(); }
>
> }
>
>
> In CommItem class I have two properties named "name" & "position"
> with getter, setters...
>
>
> UI looks good and zone ajax also working good.
>
> void onSelectedFromTopLevel() { System.out.println("Selected button
> item is --> "); }
>
> ----> Here in this method I need the selected item's index or name?
> How can I do that?
>
> I have used t:context like below:
>
> <input t:type="submit" t:id="topLevel" t:context="videoItem"
> t:value="${videoItem.name}" />
>
> and in java
>
> void onSelectedFromTopLevel(List<CommItem> i) {
> System.out.println("Selected button item size --> " +
> i.isEmpty()); }
>
> and it said the list item is empty no elements
>
> Any help?
>
> -- View this message in context:
> http://tapestry.1045711.n5.nabble.com/How-to-send-the-selected-button-value-from-tml-page-to-corr-java-page-tp5709890.html
>
>
Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
>
>
To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk+yNdgACgkQbmZsMyUPuXTkYQCfXQoW9ZP2quGbyUZMVf46b9zh
mwcAoLEZ2ck8dqkp33B4gkeeoJauiqTq
=/2hQ
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]