dev@jsftemplating.java.net

Re: JSFTemplating: List as input type for handler

From: Priti Tiwary <Priti.Tiwary_at_Sun.COM>
Date: Mon, 09 Oct 2006 11:05:20 -0700

Hi Anissa,

Did you try #{} or $attribute{}
i think this two should help...

I had worked with Lists once while trying for tables and was able to
debug it well with the use of dumpAttributes handler..
I am sending you the relevant piece of code
<!beforeCreate
    createList(size="$int{0}" result=>$page{selectedRows})
/>


where
<sun:button..
   <!command
setAttribute(key="aSelectedVal" value="anyvalue");
                             
createMap(result=>$attribute{mapName});
mapPut(map="$attribute{mapName}" key="aVal" value="#{aSelectedVal}");

                                getList(list="#{selectedRows}" //Note
passing list here.. newEntry="$attribute{mapName}")

     /**
     * <p> This method prints all the List by appending .
     * <p> Input value: "id" -- Type: <code>java.lang.String</code></p>
     * <p> Input value: "required" -- Type:
<code>java.lang.String</code></p>
     * @param context The HandlerContext.
     */
    @Handler(id="getList",
    input={
        @HandlerInput(name="list", type=List.class, required=true),
        @HandlerInput(name="newEntry", type=Object.class, required=true)
    })
    public static void getList(HandlerContext handlerCtx) {
        List<Object> list = (List<Object>) handlerCtx.getInputValue("list");
        Object newEntry = handlerCtx.getInputValue("newEntry");
        if (list != null)
            list.add(newEntry);
        else {
            list = new ArrayList<Object>();
            list.add(newEntry);
            list.add(newEntry);
        }
    }

HTH...
println and DumpAttributes helped me debug the whole processing much
clearly..

priti

Anissa Lam wrote On 10/09/06 09:59 AM,:

>Hi Ken,
>
>Does handler takes in a List as the input type ? I have the following,
>and i want to pass the output from getList() to be the input for
>doSomething().
>Maybe i don't have the syntax right, but i just can't it to work. I can
>use Array instead of List if List is not supported.
>
><!command
> getList( outList=>$attribute{myList});
> doSomething(theList=${myList}) <==== Whats the correct syntax ?
>/>
>
>@Handler(id="getList",
> output={
> @HandlerOutput(name="outList", type=java.util.List.class)})
>
>
>@Handler(id="doSomething",
> input={
> @HandlerInput(name="theList", type=java.util.List.class,
>required=true)})
>
>thanks
>Anissa.
>
>

-- 
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Priti Tiwary          		M/S SCA16-2425
Sun Microsystems, Inc.		4160 Network Circle
Voice: +1 408 276 5559          Santa Clara, CA 95054      
Cell: +1 510 396 4431           United States