On 2/12/06, Mark Lowe <[EMAIL PROTECTED]> wrote:
Okay

I've decided to let the renderer do the work of rendering parent and
children. Moving on from that I'm having trouble understanding where I
want to add child components. Doing this in the renderer seems wrong
as I want to have different validators associated with components
depending on a which country the component is being created for..

I want to do something like

if("EN".equals(mycomponent.getCountry ()) {
    //add UIInputs according to this country.
}

I'm just unsure which method in UIComponent I want to do this in.

This is the kind of use case where Shale's[1] "view controller" API becomes useful.  The prerender() method is a perfect place to do this sort of thing -- it is called immediately before rendering, even on the initial display of a page.

You can do the same thing yourself without Shale, but it's quite a bit more work -- define a PhaseListener that listens for Render Response phase, and set things up in the beforePhase() method.  But it's a lot easier to let the framework call you at the right time.

Mark

Craig

[1] http://struts.apache.org/struts-shale/

Reply via email to