You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Eugen Bushuev <bu...@lucky.net> on 2003/07/02 09:39:10 UTC

arrays

Hi.
I need to present user with list of some items (say, goods) as 
textfields and correspondent submit buttons to easy update those values. 
In PHP it looks something like that:
<?
  if (!is_array($items)) {
    $items = array(1=>"aaa", 2=>"bbb", 3=>"ccc");
  }

  if (is_array($save)){
    $key = current(array_keys($save));
    $items[$key] = $items[$key];
  }
 
?>
<html>
 <form action=test.php method=post>
  <?
    foreach (array_keys($items) as $key){
      echo "
        <input type=text   name=items[$key] value=\"$items[$key]\">
        <input type=submit name=save[$key]       value=\"Save\">
        <br><br>
      ";
    }
  ?>
 </form>
</html>

How should it be done in Struts? Using plain jsp i used to do almost all 
the same as in PHP, but it looked quite clumsy (submit name was parsed 
for index, etc...).

wbr, eugen.



-- 
С уважением, Е.Бушуев.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: arrays

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Use an iterate taglib tag - there's the standard struts ones or the JSTL 
ones. Or even the nested-beans tags. There are many ways to do this. 
Check out the Resources section on the struts website for examples or 
tutorials.

Adam

Eugen Bushuev wrote:
> Hi.
> I need to present user with list of some items (say, goods) as 
> textfields and correspondent submit buttons to easy update those values. 
> In PHP it looks something like that:
> <?
>  if (!is_array($items)) {
>    $items = array(1=>"aaa", 2=>"bbb", 3=>"ccc");
>  }
> 
>  if (is_array($save)){
>    $key = current(array_keys($save));
>    $items[$key] = $items[$key];
>  }
> 
> ?>
> <html>
> <form action=test.php method=post>
>  <?
>    foreach (array_keys($items) as $key){
>      echo "
>        <input type=text   name=items[$key] value=\"$items[$key]\">
>        <input type=submit name=save[$key]       value=\"Save\">
>        <br><br>
>      ";
>    }
>  ?>
> </form>
> </html>
> 
> How should it be done in Struts? Using plain jsp i used to do almost all 
> the same as in PHP, but it looked quite clumsy (submit name was parsed 
> for index, etc...).
> 
> wbr, eugen.
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org