Note that there are some explanatory texts on larger screens.

plurals
  1. POStruts2 using s:checkbox with c:forEach for selective Trade data records select
    primarykey
    data
    text
    <p>I have a list of records (Trades) that I need to display onto a JSP Page as tabular data from the Trade POJO and need to get checkbox selections of some of these records as Form POST back to action where I need to check which records were selected. I am doing tabular data display using <strong>c:forEach</strong>. JSP is as :</p> <pre><code>&lt;s:form id="executeTradesForm" name="executeTradesForm" action="ExeTradeAction"&gt; &lt;table id="tradesForDisplayTable" border="1" align="left" width="100%"&gt; &lt;tr&gt; &lt;s:checkbox name="selAllTradeIds" fieldValue="selAllTradeIds"/&gt; &lt;th&gt;Trade ID&lt;/th&gt; &lt;th&gt;Trade Source&lt;/th&gt; &lt;th&gt;Currency&lt;/th&gt; &lt;th&gt;Trade Status&lt;/th&gt; &lt;th&gt;Trade Date&lt;/th&gt; &lt;th&gt;Start Date&lt;/th&gt; &lt;th&gt;Maturity Date&lt;/th&gt; &lt;th&gt;Trader Name&lt;/th&gt; &lt;th&gt;Trade Quantity&lt;/th&gt; &lt;th&gt;Trade Price&lt;/th&gt; &lt;th&gt;Buy / Sell&lt;/th&gt; &lt;/tr&gt; &lt;c:forEach var="trade" items="${tradesList}" varStatus="stat"&gt; &lt;tr&gt; &lt;td&gt;&lt;s:checkbox name="selTradeId" fieldValue="selTradeId"/&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${trade.tradeId}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${trade.tradeSource}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${trade.currency}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${trade.tradeStatus}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${trade.tradeDate}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${trade.startDate}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${trade.maturityDate}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${trade.traderName}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${trade.tradeQuantity}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${trade.tradePrice.value}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${trade.buySell}" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/c:forEach&gt; &lt;s:submit align="left" name="submit" value="Execute Trades" /&gt; </code></pre> <p>What is the best approach here in terms of using <strong>s:checkbox</strong> or something else like <strong>s:checkboxlist</strong> . </p> <p>I need to know if when using <strong>s:checkbox</strong> can we have <strong>fieldValue</strong> attribute as something dynamic like '<strong>checkbox-</strong>' (tradeId being unique and coming from trade.tradeId. How to get that dynamic attribute?</p> <p>Assuming tradeId is a string value like TRD12345, what will the Action class store it as ? String[] or boolean array ? (when we use s:checkbox)</p> <p><em>Struts2 docs is wanting and has not given enough examples of using s:checkbox with collections etc.</em></p>
    singulars
    1. This table or related slice is empty.
    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