You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ja...@profinit.cz on 2005/04/15 15:41:26 UTC

Dynamic form howto

Hi,

How can I do a dynamic form (a form which content - number and type of
input elements (input fields, checkboxes, ..) is known at runtime) ?
I was thinking about a component, but this component probably cannot have a
html template (which is static). I could certainly print all the component
content in a render method, but how to take adventage of all the tapestry
support for html forms ?

thanks Jan




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


Re: Dynamic form howto

Posted by "t.n.a." <tn...@sharanet.org>.
Jan.Zelenka@profinit.cz wrote:

>Hi,
>
>How can I do a dynamic form (a form which content - number and type of
>input elements (input fields, checkboxes, ..) is known at runtime) ?
>I was thinking about a component, but this component probably cannot have a
>html template (which is static). I could certainly print all the component
>content in a render method, but how to take adventage of all the tapestry
>support for html forms ?
>  
>
Don't really see where's the problem. Take a look at the example below: 
it illustrates a page in a very simple telephone polling application. 
The poll has multiple questions all of which have any number of offered 
answers: all lists are read from page bean properties. The "priPrihvati" 
listener retrieves the information stored in the page variable 
"odabraniOdgovori" and does what ever it needs to do with it. The form 
could easily be expanded to handle an arbitrary number of different 
types of input fields (text, datetime and so on).

                    <form jwcid="@Form">
                            <br/>
                            <span jwcid="@Foreach" source="ognl:pitanja" 
index="ognl:rBrPitanje" value="ognl:pitanje">
                                <span jwcid="@RadioGroup" 
selected="ognl:odabraniOdgovori[rBrPitanje]">
                                    <span jwcid="@Insert" 
value="ognl:pitanje.tekst"/><br/>
                                        <span jwcid="@Foreach" 
source="ognl:getPonudjeniOdgovori(pitanje)" value="ognl:ponudjeniOdgovor">
                                            <input type="radio" 
jwcid="@Radio" value="ognl:ponudjeniOdgovor"/>
                                            <span jwcid="@Insert" 
value="ognl:ponudjeniOdgovor.tekst"/><br/>
                                        </span>
                                </span>
                                <br/>
                            </span>
                            <hr/>
                            <input type="submit" jwcid="@Submit" 
label="Prihvati!" listener="ognl:listeners.priPrihvati"/>
                    </form>

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