This discussion is archived
7 Replies Latest reply: Nov 13, 2003 10:56 AM by 157564 RSS

how to iterate through a container?

407392 Newbie
Currently Being Moderated
hi,
what is the tag that will iterate through a container and display the information in an Object

say in JSTL
we use the <c:foreach items="${collection}" var="">
that Iterates through the collection and another tag

<c:out value="${object.value}" />

to display the information in that object. Is there a simillar tag that does this in a jsp page with uix tags??

regards,
vasanth

  • 1. Re: how to iterate through a container?
    157564 Newbie
    Currently Being Moderated
    You can't use jstl inside uix tags.
    You can use scriplets like:
    <uix:list id="myLeadingList">
     <%
       for(int i=0; i<5; i++)
       {
         myLeadingList.addOption("text"+i, "value"+i);
       }
     %>
    </uix:list>
    Or you can use dataBinding like:
       <uix:xml>
         <dataScope xmlns="http://xmlns.oracle.com/uix/ui"
                     xmlns:demo="http://example.org">
           <provider>
             <data name="tableData">
               <method .../>
             </data>
           </provider>
           <contents>
             <list>
              <contents data:childData="rows@tableData">
               <option data:text="textKey"/>
              </contents>
             </list>
           </contents>
         </dataScope>
       </uix:xml>
    Please see
    http://otn.oracle.com/jdeveloper/help/topic?inOHW=true&linkHelp=false&file=jar%3Afile%3A/u01/app/oracle/product/IAS904/j2ee/OC4J_ohw/applications/jdeveloper/jdeveloper/helpsets/jdeveloper/uix_devguide_ohj.jar!/databinding.html
  • 2. Re: how to iterate through a container?
    407392 Newbie
    Currently Being Moderated
    thanks Arjuna,
    After the information that u've provided with respect to my previous postings we are prefering uix pages instead of jsp's.
    I've read the dev doc about the databinding. But I have all the background work done in java. The things that I need is probably DataProvider and the DataObjects. After I 've read the guide I am left with the question of how to integrate with my classes. Is it that another class will implement the DataProvider methods and in my main servlet class I can call the methods that are written in the DataProvider class??
    Do I need the controller component?
    or can i just use my current servlet to post the request back to the uix page? If there are any examples in the oracle site please gimme the url's.

    regards,
    vasanth
  • 3. Re: how to iterate through a container?
    157564 Newbie
    Currently Being Moderated
    You don't need to use the UIX controller/servlet.

    And you don't have to create DataObjects or DataObjectLists. UIX automatically converts Java Beans and java.util.Maps into DataObjects. And java.util.Lists into DataObjectLists.

    And you don't have to create DataProviders. You can put your data on the HttpSession.

    Let's say you have a bean like:
    public class MyAppBean
    {
      public String getUserName()
      {
       ...
      }
    
      public ArrayList getCars()
      {
      }
    }
    Let's say you placed an instance of the above bean on the session like this:
    servletRequest.getSession().setAttribute("myApp", new MyAppBean());
    Now your jsp would look like:
       <uix:xml>
         <dataScope xmlns="http://xmlns.oracle.com/uix/ui"
                     xmlns:demo="http://example.org">
           <contents>
            <styledText data:text="userName@myApp@httpSession"/>
            <list>
             <contents data:childData="cars@myApp@httpSession">
              <option .../>
             </contents>
            </list>
           </contents>
         </dataScope>
       </uix:xml>
  • 4. Re: how to iterate through a container?
    407392 Newbie
    Currently Being Moderated
    hi Arjuna,
    I have this example here that does not work as intended even if i used the bean set to a request with the request.getSession().setAttribute("controlViewBean", controlViewBean);
    controlViewBean holds PanelDimensions object which holds PortletDimension which has a name. There are 3 PortletDimensions.

    If I put the dataScope in this the code gives an error.
    Do i need to specify a dataProvider in my jsp? or should the dataScope tag in your example take care of it?
    here is my code

    <uix:form name ="test method = "get" />
    <uix:xml>
    <uix:styledText text="Dimensions"/>
    <uix:contents childData="@panelDimensions@controlViewBean@httpSession">
    <uix:list>
    <uix:option text="name@portletDimension@panelDimensions@controlViewBean@httpSession">
    </uix:option>
    </uix:list>
    </uix:contents>
    </uix:xml>


    And if i use
    <uix:contents data:childData="some thing here">
    <uix:contents>
    the error is thrown at data saying that data is not a valid tag in this context!

    even this is throwing an error

    <dataScope xmlns="http://xmlns.oracle.com/uix/ui" >



    why do I have to use the data: tag? is it to specify that I am using dataBinding?

    regards,
    vasanth
  • 5. Re: how to iterate through a container?
    157564 Newbie
    Currently Being Moderated
    yes, the data: prefix is used to specify that that attribute is databound. However, before you use "data:" you need to define the "xmlns:data" attribute.

    Is this throwing an error:
    <uix:xml>
     <dataScope xmlns="http://xmlns.oracle.com/uix/ui" />
    </uix:xml>
    if so, what is the error?
  • 6. Re: how to iterate through a container?
    4996 Newbie
    Currently Being Moderated
    What is the difference between using the "data:" prefix and the "Binding" suffix?

    e.g.

    <uix:text data:text="bean.property" /> vs.
    <uix:text textBinding="bean.property" />
  • 7. Re: how to iterate through a container?
    157564 Newbie
    Currently Being Moderated
    when UIX is run via XML, attributes that were data bound were prefixed with data:.

    However, in JSP there is no notion of prefixed attributes.
    So when UIX is run via JSP, we use the Binding suffix to indicate that an attribute is data bound.

    Furthermore, when you use the <uix:xml> tag inside a JSP it parses its children like they were in XML mode; so the data: prefix is recognized inside <uix:xml>.

    In JSP 2.0 the data binding syntax is very similar between UIX/XML and UIX/JSP because of EL support.