Your component must implement IFormComponent or extends AbstractFormComponent.

then you override those two method:
renderFormComponent(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IRequestCycle cycle)
---> here you render the html for your form component
rewindFormComponent(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IRequestCycle cycle) --> here you get the value from the post (cycle.getParameter(getName ())) and update you field

Numa

Le 27 mars 07 à 16:03, mxc a écrit :


Hi all,

I am new to tapestry and trying to write a component. The component is
basically a drop down box which will be used to filter the results of a database query. The reason I want it as a component is that it will be used on many pages. I am also using this to understand tapestry better so I am using the AbstractComponent base class for rendering the select box. I know this can be done using BaseComponent but would prefer to get it working with
the current (AbstractComponent) setup.

My current understanding is that variables for the page class are populated from the request parameters during the "rewind" phase of the RequestCycle.
My select box is submitted when a form is posted to the server. The
selection should be read and then used to filter the query results and then
return the current page with the new results.


Here is my ProvinceDropDown.java

package za.co.jumpingbean.wazzup.smsapp.ui.web.pages.components;

@ComponentClass (allowBody = false, allowInformalParameters = true)
public abstract class ProvinceDropDown extends AbstractComponent {
        
        @InjectSpring("lookupService")
        public abstract LookupService getLookupService();       
        
        public abstract void setProvince(Province province);
        public abstract Province getProvince();

        
        public Province getDefault(){
                return null;
        }
        
        @Override
        public void finishLoad(IRequestCycle arg0, IPageLoader arg1,
IComponentSpecification arg2) {
                // TODO Auto-generated method stub
                super.finishLoad(arg0, arg1, arg2);
        }

        @Override
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) {
                LookupService service = getLookupService();
                List <Province> list = service.findProvinces();
                writer.begin("select");
                renderInformalParameters(writer, cycle);
                for (Province province : list){
                                writer.begin("option");
                                        writer.attribute("name", 
province.getId());
                                        writer.print(province.getName());
                                writer.end();
                }
                writer.end();
        }
}


Here is my ProvinceDropDown.jwc

<?xml version="1.0"?>
<!DOCTYPE component-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 4.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
<component-specification
class="za.co.smsapp.ui.web.pages.components.ProvinceDropDown"/>

Here is how I am using it in my ListCities.html


<html title="Wazzup - List Cities" jwcid="@Shell">
    <head>
    </head>
    <body jwcid="@Body">
        <form jwcid="@Form" success="listener:doFilter">
                                
                                <input type="submit" value="filter" />
        </form>
        <table
columns="ID:id,Province:province.name,Name:name,!Regions,!Delete,! Edit"
source="ognl:citiesTableModel" jwcid="@contrib:TableView">


What I am trying to do if have the variable "province" in the
jwcid="provinceDropDown" populated by the selected province so that it can
be set in the parent component to be used in running the query which
populated "citiesTableModel. The variable is currently always NULL.

So stepwise

1) User select province
2) Clicks "filter" button
3) The province that is selected is deserialized or recreated and set in the
ProvinceDropDown class.
4) As this is also a parameter it will be set in the ListCities class
5) The ListCities class reads the province vallue and executes the selected
6) The page is returned.

Any pointer to tuts etc appreciated.

--
View this message in context: http://www.nabble.com/How-are-post- variables-converted-to-objects--tf3473298.html#a9693036
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to