This discussion is archived
5 Replies Latest reply: Dec 18, 2003 2:47 PM by 6015 RSS

Refer to 'parent' 'uix.current'?

4996 Newbie
Currently Being Moderated
I'm using the 10g preview. I'm trying to do something like this:
<contents childData="${ bean.thingsToChoose }" >
<messageChoice prompt="${ uix.current.name }"
          name="${ uix.current.name }"
          >
    <contents childData="${ bean.childrenOf[ uix.current['.'] ] }" >
     <option text="${ uix.current.name }" >
     </option>
    </contents>
</messageChoice>
</contents>
Let's say the bean has a method like 'selectedChildOf', so that in the option tag, I'd like to say something like:
selected="${ uix.current['.'] eq bean.selectedChildOf[ uix.current['.'] }"
Except the second occurrence of 'uix.current' there actually needs to refer to the current object in the outer loop, not the current object of the inner loop. (By the way, is that the correct comparison syntax - i.e. same as JSTL el?)

I know that I could add a property to the children so that they could know whether they are selected, but I'd rather not do that just yet. If possible, could someone please point out both:

1) How to refer to the outer loop's current object from inside the inner loop?

2) How to set up a temporary variable or alias? This would be one way to make the reference - i.e. something like the following, only in UIX:
<c:set var="outerCurrent" value="${ uix.current['.'] }" />
Thanks!
  • 1. Re: Refer to 'parent' 'uix.current'?
    4996 Newbie
    Currently Being Moderated
    bounce
  • 2. Re: Refer to 'parent' 'uix.current'?
    55663 Newbie
    Currently Being Moderated
    I'll talk to one of our EL experts and let you know what
    I find out.
  • 3. Re: Refer to 'parent' 'uix.current'?
    157564 Newbie
    Currently Being Moderated
    1. Unfortunately, there is no way to refer to the 'parent' uix.current.

    This is a serious limitation and we are going to fix this for the JSF release of UIX.

    2. Most Unfortunately, there is also no way of setting a temporary variable. The workaround is to write and register an EL Function that will take a Map, a key and a value and set the value on the Map. Then you can use that to set a temporary value on the requestScope.

    To create your own EL functions, you need to write a UIExtension.
    And in the
    registerSelf(ParserManager manager) 
    method, you will use
    XMLUtils.registerFunctions(
     ParserManager manager, 
     String namespace, Class klass)
    to register all the public static methods in klass as EL functions, under the specified namespace.
  • 4. Re: Refer to 'parent' 'uix.current'?
    4996 Newbie
    Currently Being Moderated
    Thanks, Arjuna. Could you please confirm the following implementation? It appears to be working, but I want to be sure I haven't overlooked something that will get me into trouble down the line. Also, if this is a correct implementation, I thought it might be nice to have an example here that others could learn from or use.
    public class TempValueUIExtension implements UIExtension  {
    
         public static final String TEMP_VALUE_NAMESPACE = "http://tempvalue.avega.com";
    
         public TempValueUIExtension() {
         }
    
         public void registerSelf(ParserManager parserManager) {
         
              XMLUtils.registerFunctions( parserManager, TEMP_VALUE_NAMESPACE, TempMap.class );
         }
    
         public void registerSelf(LookAndFeel lookAndFeel) {
         }
    
    }
    
    public class TempMap {
         
         public static final String MAP_ATTRIBUTE = "tempMapAttribute";
         
         public static void put( UIImplicitObject uix, Object key, Object value ) {
              getTempMap( uix ).put( key, value );
         }
         
         public static Object get( UIImplicitObject uix, Object key ) {
              return getTempMap( uix ).get( key );
         }
         
         private static Map getTempMap( UIImplicitObject uix  ) {
              
              RenderingContext context = uix.getRenderingContext();
              BajaContext bajaContext = BajaRenderingContext.getBajaContext( context );
              HttpServletRequest request = bajaContext.getServletRequest();
         
              Map tempMap = (Map)request.getAttribute( MAP_ATTRIBUTE );
              if ( tempMap == null ) {
                   tempMap = new HashMap();
                   request.setAttribute( MAP_ATTRIBUTE, tempMap );     
              }
              return tempMap;
         }
    }
    
    <?xml version="1.0" encoding="windows-1252"?>
    <page xmlns="http://xmlns.oracle.com/uix/controller"
          xmlns:temp="http://tempvalue.avega.com" expressionLanguage="el">
        <content>
            <dataScope xmlns="http://xmlns.oracle.com/uix/ui">
                <contents>
                    <document>
                        <contents>
                            <body>
                                <contents>
                                    <text text="${ temp:put( uix, 'tempKey', 'tempValue' ) }"/>
                                    <text text="${ temp:get( uix, 'tempKey' ) }"/>
                                </contents>
                            </body>
                        </contents>
                    </document>
                </contents>
            </dataScope>
        </content>
    </page>
    I've got the TempValueUIExtension registered in the uix-config.xml. The output of the above test page renders as just the string 'testValue', which is what I would expect. I wasn't sure where to include the el for setting the value, but since it is a null function, I figured it couldn't hurt to throw in a <text> tag that would probably just print nothing at all. Any better suggestions?

    Also, you say there will be a way to refer to outer loops in the next release of UIX (do you mean the 10g production release, or after that?) Will there also be a built-in mechanism for temporary variables?
  • 5. Re: Refer to 'parent' 'uix.current'?
    6015 Newbie
    Currently Being Moderated
    Hi,

    The JSF release is the release after JDeveloper 10g Production.

    Thanks,
    Jonas