Note that there are some explanatory texts on larger screens.

plurals
  1. POTapestry, Get selected item from loop
    primarykey
    data
    text
    <p>I'm currently working on some project, using Apache Tapestry 5.3.6. I have issue using t:loop component. Is there any way I can get selected item after loop finishes, and page is rendered? What I need to achieve is: Let's say I have loop like this:</p> <pre><code>&lt;t:loop t:source="itemList" t:value="item"&gt; &lt;t:actionlink id="something" context="item.ID"&gt;&lt;/t:actionlink&gt; &lt;/t:loop&gt; </code></pre> <p>This will work fine. But if I move this actionlink into my own component, and pass this ID through my parameter, if I click, I always get the last item from list, and not the one which is clicked.</p> <pre><code>&lt;t:loop t:source="itemList" t:value="item"&gt; &lt;t:mycomponent myparameter="item.ID"&gt;&lt;/t:mycomponent&gt; &lt;/t:loop&gt; </code></pre> <p>I tried putting formState="iteration", and puting ValueEncoder, but nothing helps. Please, can anyone help me, and show me how to solve this issue, and get the selected item from the list. Thanks in advance</p> <p>Edit: Here is code of my component</p> <pre><code>public class Ocenjivanje { @Parameter(required=true) @Property private int materijalID; private Materijal materijal; @Inject private Session session; @SessionState private User user; @CommitAfter public Object unesiOcenu(int ocena) { Materijal m = (Materijal)session.createCriteria(Materijal.class).add(Restrictions.eq("materijalID", this.materijalID)).list().get(0); Date d = new Date(); Ocena o = new Ocena(); o.setMaterijal(m); o.setKorisnikID(this.user.getID()); o.setDatumOcene(d); o.setOcena(ocena); session.save(o); return this; } public void onActionFromJedan() { unesiOcenu(1); } public void onActionFromDva() { unesiOcenu(2); } public void onActionFromTri() { unesiOcenu(3); } public void onActionFromCetiri() { unesiOcenu(4); } public void onActionFromPet() { unesiOcenu(5); } } &lt;t:container xmlns="http://www.w3.org/1999/xhtml" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter"&gt; Oceni sadržaj: &lt;t:actionlink t:id="jedan"&gt;1&lt;/t:actionlink&gt; &lt;t:actionlink t:id="dva"&gt;2&lt;/t:actionlink&gt; &lt;t:actionlink t:id="tri"&gt;3&lt;/t:actionlink&gt; &lt;t:actionlink t:id="cetiri"&gt;4&lt;/t:actionlink&gt; &lt;t:actionlink t:id="pet"&gt;5&lt;/t:actionlink&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload