Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2220 > unrolled thread

Passing value from Struts

Started by"Oleg Konovalov" <oleg.konovalov@THRWHITE.remove-dii-this>
First post2011-04-27 15:37 +0000
Last post2011-04-27 15:37 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.java.gui


Contents

  Passing value from Struts "Oleg Konovalov" <oleg.konovalov@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000
    Re: Passing value from St "Richard Senior" <richard.senior@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000

#2220 — Passing value from Struts

From"Oleg Konovalov" <oleg.konovalov@THRWHITE.remove-dii-this>
Date2011-04-27 15:37 +0000
SubjectPassing value from Struts
Message-ID<5Ojvi.2171$Ns6.2064@trnddc01>
  To: comp.lang.java.gui,comp.l
Hi,

 I am populating JSP page with rows retrieved from the database and 
represented as a List of Beans in forEach loop:
<c:forEach var="list" items="${OperationsForm.OperationsList}">
          ...
  <c:choose>
            <c:when test="${list.isCompleted =='Y'}" >
                <td width="100">Completed</td>
                <td width="100">&nbsp;</td>
            </c:when>
            <c:otherwise>
                <td width="100">Pending</td>
                    <td width="100"><input type="image" onclick=" 
rowId=value; form.action='action.do?command=notify'" 
value="${list.OperationId}" />
                    </td>
            </c:otherwise>
            </c:choose>
            </tr>
        </c:forEach>
Have hidden field:  html:hidden property="rowId" value="-1"/>

User is clicking the button corresponding to one of the rows
and I need to pass the  value of that  rowId to the Action class, so it does 
something in the database [action completed]
Now how do I pass it , is that the right way of doing it  with calling
request.getSession().getAttribute(rowId) in the Action class ?
As of now I am getting Javascript error "Object doesn't support this 
property or method", complaining about rowId=value;

Using Struts 1.3

Please help !

TIA,
Oleg.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#2226 — Re: Passing value from St

From"Richard Senior" <richard.senior@THRWHITE.remove-dii-this>
Date2011-04-27 15:37 +0000
SubjectRe: Passing value from St
Message-ID<f9s4hl$4q7$1$8300dec7@news.demon.co.uk>
In reply to#2220
  To: comp.lang.java.gui,comp.l
Oleg Konovalov wrote:

> User is clicking the button corresponding to one of the rows
> and I need to pass the  value of that  rowId to the Action class, so it does 
> something in the database [action completed]
> Now how do I pass it , is that the right way of doing it  with calling
> request.getSession().getAttribute(rowId) in the Action class ?
> As of now I am getting Javascript error "Object doesn't support this 
> property or method", complaining about rowId=value;

You don't need JavaScript. Use the Struts <html:button> tag:

<html:form action="myActionInStrutsConfig">

     ...

     <c:forEach var="item" items="${OperationsForm.OperationsList}">

         <html:button property="x" value="${item.OperationId}" />

     </c:forEach>

</html:form>

When the button is pressed, the form is submitted and you get a request 
parameter "x" available to your Action set to the operation id value 
that's on the button. Obviously you'll have a better name for "x".

-- 
Regards,

Richard

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web