Meaningless Drivel is fun!
The moose likes Struts and the fly likes Problem with Struts and javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with Struts and javascript" Watch "Problem with Struts and javascript" New topic

Problem with Struts and javascript

Anna Ferrari

Joined: Aug 18, 2006
Posts: 14
from my first jsp I call with javascript another jsp for select one item from a table,the second jsp update two attribute in the first one jsp. My problem is that :I desire to re-use the second jsp in many situations, but with my code i can't.

This is the first jsp :


<td><html:text property="moaridDesc" /></td>
<td><html:hidden property="moarid" /></td>
<td><html:input type="button" name="choise"
onKlick="'<thtml:rewrite page='/'/>', ' ', width=500,height=400, top=100, left=700');" value="Ricerca"></td>

This is the second jsp :


<SCRIPT language="Javascript">

function sendValue(arId, arcodi) {


<logic:interate name="articoloBeanForm" property="articoloDOL" id="articolo" >
<a href='javascript nKlick=sendValue(<bean:write name="articolo" property="arId" />,
"<bean:write name="articolo" property="arcodi" /> ")'>
<bean:write name="articolo" property="arcodi" /> </a>

The application works well, but the code inside sendValue reports only to movimentoBeanForm.
Any idea for resolve the problem?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You could make this function more generic like this:

The additional parameters are:

  • form - the Name of the form
  • idInput - the input used for the ID
  • descInput - the Input used for the description

  • Merrill
    Consultant, Sima Solutions
    Anna Ferrari

    Joined: Aug 18, 2006
    Posts: 14
    Thank you Merrill Higginson for your answer, I take inspiration from you to resolve my problem and then i do like this:

    In the first jsp i create three session's attributes :

    <SCRIPT LANGUAGE="JavaScript">
    function ricercaArticolo(){
    <% session.setAttribute("bf", "movimentoBeanForm");
    session.setAttribute("f1", "moarid");
    session.setAttribute("f2", "moaridDesc");
    %>'<html:rewrite page='/'/>',

    And in the second I use those three session's attributes :

    <SCRIPT LANGUAGE="JavaScript">
    function sendValue(arId, arcodi){
    window.opener.document.<%= session.getAttribute("bf") %>.
    <%= session.getAttribute("f1") %>.value = arId;
    window.opener.document.<%= session.getAttribute("bf") %>.
    <%= session.getAttribute("f2") %>.value = arcodi;

    I think this is one step on, again thanks.Bye.
    I agree. Here's the link:
    subject: Problem with Struts and javascript
    It's not a secret anymore!