You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Pranav Bihari <pb...@hotmail.com> on 2004/01/29 11:59:31 UTC

newbie: insert within foreach

Hi,

I have just started to learn about Tapestry and am trying to write my first 
application. How can one output values from a String array using Insert and 
Foreach components. It must be something very simple I am missing. Help 
would be greatly appreciated.

Here is what I am trying without success:
-----------------TEMPLATE--------------------------------
<html>
<head>
<title>Hello World</title>
</head>
<body>
   Welcome to Tapestry World! <br>
   List of countries:
    <span jwcid="countries" element="li">
     <span jwcid="@Insert"/>
    </span>
</body>
</html>

-----------------PAGE----------------------------------------
<page-specification class="hw.countries.CountriesList">
    <description>Tapestry World</description>

    <component id="countries" type="Foreach">
        <binding name="source" expression="countryNames"/>
    </component>

</page-specification>
-----------------------CLASS---------------------------------
public class CountriesList extends BasePage{
	private static final String[] countryNames = { "US", "UK", "Germany" };

	public String[] getCountryNames() {
		return countryNames;
	}

}
-----------------------------------------------------------------------

regards,
PB

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail


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


Re: newbie: insert within foreach

Posted by Programozás <pr...@hotmail.com>.
Hi!

I have modified your sources, see below.
I haven't tried it but I think it should work ;)

> <html>
> <head>
> <title>Hello World</title>
> </head>
> <body>
>    Welcome to Tapestry World! <br>
>    List of countries:
>     <ul>
>     <li jwcid="@Foreach" source="ognl:countryNames"
value="ognl:countryName" element="li">
>      <span jwcid="@Insert" value="ognl:countryName"/>
>     </li>
>     </ul>
> </body>
> </html>
>
> -----------------PAGE----------------------------------------
> <page-specification class="hw.countries.CountriesList">
>       <property-specification name="countryName" type="java.lang.String"
/>
> </page-specification>
>
> -----------------------CLASS---------------------------------
> public class CountriesList extends BasePage{
> private static final String[] countryNames = { "US", "UK", "Germany" };
>
> public String[] getCountryNames() {
> return countryNames;
> }
>
> }

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