Using a treemap for lookup in a jsp grid - Weblogic

This is a discussion on Using a treemap for lookup in a jsp grid - Weblogic ; Hi I am trying to use a treemap to lookup the names for idīs in a table. for example. Lookup table: ID.....Name 1......carrot 2......bananna the table looks like this: row....id 1.......2 2.......1 3.......1 4.......2 in my jsp page I want ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Using a treemap for lookup in a jsp grid

  1. Using a treemap for lookup in a jsp grid

    Hi

    I am trying to use a treemap to lookup the names for idīs in a table.

    for example.
    Lookup table:
    ID.....Name
    1......carrot
    2......bananna

    the table looks like this:
    row....id
    1.......2
    2.......1
    3.......1
    4.......2

    in my jsp page I want it to look like this:
    row....id
    1......bananna
    2......carrot
    3......carrot
    4......bananna

    I have the lookup table loaded into a treemap in the begin part of my pageflow.

    is there a special way that I can refer to the treemap in a grid view, for example, with a netui-data:expressionColumn ?

    thanks for any help.

    /Nigel

  2. Re: Using a treemap for lookup in a jsp grid

    ok... Im getting there

    I added a method to the pageflow like:

    public String getFruit(Long myKey)
    {
    return fruitMap.get(myKey.toString()).toString();
    }

    then added the following to my jsp:






    This, as you may guess returns the name carrot for every row.
    What I need to do now is change the value for the methodParameter so that it takes the main tablesī id
    I thought I could do this:


    but I get a nullpointerexception.

    any ideas ?

    /Nigel

  3. Re: Using a treemap for lookup in a jsp grid

    Im still stuck with this problem...

    Trying to explain the problem. Consider these lines in a jsp page:








    this works, I get 2 columns
    1st column is the utbud_id
    2nd column gives me the name for utbud_id nr 1010

    now if I replace the "1010" with "{container.item.utbud_id}" to pass the current utbud_id, I get:
    Caught exception when evaluating expression "{container.item.utbud_id}" with available binding contexts [actionForm, pageFlow, globalApp, request, session, appication, pageContext, bundle, container, url, pageInput]. Root cause: java.lang.NullPointerException

    this is very strange, as I use "{container.item.utbud_id}" in the column before.

    what am I missing ?

    thanks for any help

    /Nigel

  4. Re: Using a treemap for lookup in a jsp grid

    hi,

    important here to aknowledge that the {} databinding are compile time. This implies a whole lot of restrictions. The scenario below works for me:

    - getLookupMap in the pageflow returns the lookup map
    - getList in the pageflow returns the list

    The following code then works for me


    // get the lookup map into pagecontext
    value="{pageFlow.lookupMap}"/>

    // pull down as a new page attribute
    <%
    Map lookup = (Map)pageContext.getAttribute("lookup");
    %>

    Now, in my repeater ( of gridview ) I implement the column showing the actual mapped value like this:

    // to get the item key
    value="{container.item}"/>

    // to set the mapped attribute value
    <%
    pageContext.setAttribute(
    "lookupValue",
    lookup.get(pageContext.getAttribute("key")));
    %>

    // to render the mapped attribute value
    defaultValue=" " />


    Probably not exactly what you asked for, but hopefully close enough to guide you in the right direction.

    - Anders M.

+ Reply to Thread