Iterate through a list containing Map items using struts

Hi friends,
I have a small problem. I want to iterate through a list of items, using struts.
The list actually contains map structres for example:
list(0)
     map(..key..value..)
     map(..key..value..)
     map(..key..value..)
list(1)
     map(..key..value..)
     map(..key..value..)
     map(..key..value..)
list(2)
     map(..key..value..)
     map(..key..value..)
     map(..key..value..)can I use <logic:iterate/> for this? if yes how? Because I have used this tag for list containing bean objects not Map.
Any suggestions are much appreciated.
Thanks,
Vishal

Normally, each object exposed by the iterate tag is an element of the underlying collection you are iterating over. However, if you iterate over a Map, the exposed object is of type Map.Entry that has two properties:
key - The key under which this item is stored in the underlying Map.
value - The value that corresponds to this key.
So, if you wish to iterate over the values of a Hashtable, you would implement code like the following:
<logic:iterate id="element" name="myhashtable">
Next element is <bean:write name="element" property="value"/>
</logic:iterate>
Best Regards
Maruthi

Similar Messages

  • Iteration through a list of map entries

    hi,
    I am facing a situation in which i have to write a rule to iterate through a list of map entries within a map and again iterate for a given attribute through a map of attributes within the selected map entry.
    Can anyone throw light on any function or expression in the XPRESS language in the Identity Manager to accomplish this.
    thanx in advance,
    yashuwyah

    HI,
    I cant help you out with full code at this point. But do make use of the following to determine the equivalency between GenericObject and HashMap as shown below.
    Basic Operations
    � map.keySet() == genObj[*].name
    � map.entrySet() == genObj[*]
    � map.get(attribute) == genObj.attribute
    � map.get(attribute1).get(attribute2).get(employeeNumber) ==
    genObj. attribute1. attribute2.employeeNumber� if attribute1 indexes a list object in the preceding example ==
    genObj. attribute1[attribute2].employeeNumber� Searches
    � find the object with the attribute fullname = �John Smith� ==
    genObj[fullname=John Smith]� get John Smith�s employeeNumber == genObj[fullname=John
    Smith].employeeNumber� List Operations
    � get the names of all permanent employees ==
    genObj[employeeType=permanent].nameFor your requirements, I figure that you can iterate through the list in the beginning and assign the initial result to a <defvar>. Then use the reference of this to determine the required attributes next.
    IC.

  • How to determine if string contains HashSet item using LINQ

    Hi,
    I know how to iterate through a HashSet to see if an item is contained in a string.  But, I can't quite figure out how to do it with LINQ.
    Something like if( string.Contains(???))
    I would appreciate any help!
    Thanks much!!

    Thanks everyone.  I like the examples posted above.
    Actually, what I want to know is if any HashSet values can be found in a string using LINQ
    HashSet<string> terminals = new HashSet<string>();
    terminals.Add("FD4A");
    terminals.Add("FD4B");
    terminals.Add("FD4C");
    //a collection of a bunch of transactions done at various terminals
    List<string> transactionList = new List<string>();
    foreach (string transaction in transactionList)
        foreach (string terminal in terminals)
           if (transaction.Contains(terminal) == true)
                //this is one of the transactions I want - do something
                break;
    Thanks much and have a great weekend!!

  • Iterate through two lists

    Hello,
    I'm writing an application that generates two seperate sets of data from a database which are stored in two lists; list A & B. I need to cycle through one list (*B*) and remove data according to my search criteria. When I encounter data that I'm going to remove, it has to be done on list A as well.
    Is it at all possible to use one iterator to cycle through list B and modify A at the same time? If so, please explain.

    For those who are interested, here is the code I used to solve the problem. All the writers create an html booklet for easy interpretation. And yes, I did take into consideration the fact that removing an item from the list offsets the counter and will skip n+1. The use of while( cdList.contains( trimmedcdValue )) was introduced to handle such a case by continuing to delete duplicates (by grabbing their subscript) within the list.
              try{
                   statWriter=new BufferedWriter(new FileWriter("results/"+directory+"/FileStatistics.html"));
                   statWriter.write(this.buildHeader("File Statistics"));
                   statWriter.write("<table class='file-stats'><tr><th>File #</th><th>File name</th><th>Lines read</th><th>Total matches</th></tr>");
                   writer=new BufferedWriter(new FileWriter("./results/"+directory+"/MatchList.html"));               
                   writer.write(this.buildHeader("Matched References"));
                   writer.write("<table><tr><th>File Line</th><th>CD Reference</th><th>ATA Number</th><th>Log_Book</th><th>Description</th><th>File Found in</th></tr>");
                   //loop through all new files
                   for(int y=0; y<f.length; y++){
                             //update the progressbar information
                        this.updateProgress(f[y]);
                        //set file reader
                        reader=new BufferedReader(new FileReader("./id files/"+directory+"/"+f[y]));
                        int lineCount=0;     //keep track of lines read
                        int match=0;          //keep track of the matches
                        String line=null;
                        while((line=reader.readLine())!=null){
                             String trimmedLine=line.trim();          //remove leading/trailing whitespace
                             lineCount++;                              //increment line counter
                                  //cycle through list and check for matches
                             for(int x=0; x<cdList.size();x++){
                                  String cdValue=(String)cdList.get(x);               //current list subscript
                                       //remove leading/trailing whitespace
                                  String trimmedcdValue=cdValue.trim();                    
                                       //if matched; remove row from list
                                  if(trimmedLine.equalsIgnoreCase(trimmedcdValue)){     
                                            //while the value exists in the list; find & remove
                                       while(cdList.contains(trimmedcdValue)){
                                            match++;
                                            row=(match%2==0)?"<tr>":"<tr class='shaded'>";
                                            int index=cdList.indexOf(trimmedcdValue);
                                            writer.write(row+"<td>"+trimmedLine+"</td><td>"+cdList.get(index)+"</td><td>"+ataList.get(index)+"</td><td>"+logList.get(index)+"</td><td>"+descList.get(index)+"</td><td>"+f[y].toLowerCase()+"</td></tr>");
                                            this.removeRow(index);
                             }//end list for-loop
                        }//end line read while-loop
                        writer.flush();                    //flush writeMatch buffer
                             //write file statistics
                        row=(y%2==0)?"<tr>":"<tr class='shaded'>";
                        statWriter.write(row+"<td>"+(y+1)+" of "+f.length+"</td><td>"+f[y].toString()+"</td><td>"+lineCount+"</td><td>"+match+"</td></tr>");
                   }//end file for-loop
                   writer.write("</table></body></html>");
                   writer.close();          //close write match stream
                        //reopen write stream for new file
                   writer=new BufferedWriter(new FileWriter("./results/"+directory+"/RemainingList.html"));
                   writer.write(this.buildHeader("Remaining List"));
                   writer.write("<table><tr><th>CD Reference</th><th>ATA Number</th><th>Log Book</th><th>Description</th></tr>");
                   for(int y=0; y<cdList.size(); y++){
                        row=(y%2==0)?"<tr>":"<tr class='shaded'>";
                        writer.write(row+"<td>"+cdList.get(y)+"</td><td>"+ataList.get(y)+"</td><td>"+logList.get(y)+"</td><td>"+descList.get(y)+"</td></tr>");
                   writer.write("<tr><td colspan='4'>Remaining list size: "+cdList.size()+"</td></tr></table></body></html>");
                   writer.flush();                    //flush writeList Stream
                   writer.close();                    //close     writeList stream
                        //display operation statistics
                   endingListSize=cdList.size();
                   statWriter.write("<tr><td colspan='2'>Beginning list size:</td><td colspan='2'><strong>"+beginningListSize+"</strong></td></tr>");
                   statWriter.write("<tr class='shaded'><td colspan='2'>Null CD References removed:</td><td colspan='2'><strong>"+nulls+"</strong></td></tr>");
                   statWriter.write("<tr><td colspan='2'>ENG Log values removed:</td><td colspan='2'><strong>"+engs+"</strong></td></tr>");
                   statWriter.write("<tr class='shaded'><td colspan='2'>Ending list size:</td><td colspan='2'><strong>"+endingListSize+"</strong></td></tr>");
                   statWriter.write("</table></body></html>");
                        //flush and close stat writer stream
                   statWriter.flush();
                   statWriter.close();
              }catch(IOException ioe){
                   ioe.printStackTrace();
              }     If you care to actually look through all this code, there is a call to removeRow which deletes the selected item from each list and is as follows...
         private void removeRow(int x){
                   //remove identical row for each column
              cdList.remove(x);
              ataList.remove(x);
              logList.remove(x);
              descList.remove(x);
         }Thanks to everyone who invested time in this problem, but fortunately enough the problem was solved outside of this forum.

  • In terms of memory utilization which is better to iterate through a LIST?

    For Loop or Iterator Class.?????

    1. For loop and Iterator are not mutually exclusive. One common way to iterate before the foreach loop introduced in 1.5 (my preferred way) was like so:
    for (Iterator iter = list.iterator(); iter.hasNext();) {
      Object obj = iter.next();
    }2. By "for loop" I assume you mean "using get()". NEVER iterate using get(). It will work fine on ArrayList, but will be crappy slow on LinkedList, and doesn't exist on Set or Collection. Using an Iterator (or foreach, which is syntactic sugar for an Iterator) means you'll get proper and consistent behavior on any colleciton.
    3. The memory usage will not be any different, or will be ridiculously insignificant. This kind of microoptimization without hardcore profiling numbers is a good way to gain a tiny, meaningless bit in one area at a much larger cost in another area.
    Just use a foreach loop, or in cases where you need to modify the collection under iteration, an explicit Iterator or ListIterator.

  • Iterating through List View Items using Group By and Jquery

    In my listview to my document library, I am using grouping. For each group (using month), it lists all the documents pertaining to that particular month.
    Using JQuery, I need to go through each item and parse them, but I'm having trouble finding a usable selector for the for/each function. My parsing code (JQuery) works, but since it uses the class of the table cell with a child anchor, it basically
    finds the first item and then all the subsequent file names are named the same (instead of different names, like it should be).
    Here's my current code that doesn't work (only the iteration and naming separately for each file - the parsing I'm doing seems to work):
    $(".ms-wpContentDivSpace" ).each(function( index ) {
    var val=$(".ms-vb2 a").html();
    var val2=val.replace(/_/g," ");
    $(".ms-vb2 a").html(val2);
    any ideas?

    That's because
    $(".ms-vb2 a").
    is bringing back all the pieces that have that class with an anchor on the whole page, not just the ones in the .ms-wpContentDivSpace
    I don't know the exact syntax, but I think you need to iterate through all the '.ms_vb2 a' items as well - there are multiple ones, and do something like this inside your other grouping
    $(".ms-vb2 a").each(function(index) {
        var val=$(this).html();
       var val2=val.replace(/_/g," ")
       $(this).html(val2);
    That's not quite right but maybe that will help.
    Robin

  • TreeModel - Iterate through child records using row EL

    Hi all,
    Jdev Version: Studio Edition Version 11.1.1.7.0
    I have a search page where I need to display the search results of Header and on one of the columns need to display a concatenated list of children.
    Header is a Task and children are Assignees of the task. I am looking to achieve this by using a normal table bound to a tree binding inside which the 'Assignee' view link is added as a child. So the binding is ready. I attempt to use the af:table using the treeModel which also seems to be working fine.
    Now I am stuck on how to iterate through the assignees for each task using EL - #{row.???}
    Jsff  Code snippet
              <af:table value="#{bindings.Task1.treeModel}" var="row"
                          rows="#{bindings.Task1.rangeSize}"
                          summary="#{ResourcesGenBundle['Header.SearchResults']}"
                          varStatus="tableMetadata"
                          selectionListener="#{backingBeanScope.TaskSearchBean.selectHandler}"
                  width="100%" columnStretching="column:resId1c5" autoHeightRows="15">
                    <af:column id="c3" headerText="Assignees">
                        <af:iterator id="i1" rows="2" var="assigRow"
                                 value="#{row.Task11.collectionModel}">                 
                            <af:outputText value="#{assigRow.UserName}" id="ot2"/>
                            <af:spacer width="10" height="10" id="s2"/>
                        </af:iterator>
                    </af:column>
                </af:table>
    Page Def Snippet
        <tree IterBinding="Task1Iterator" id="Task1">
          <nodeDefinition DefName="sample.common.publicModel.components.view.TaskVO"
                          Name="Task10">
            <AttrNames>
              <Item Value="TaskId"/>
              <Item Value="Subject"/>
              <Item Value="Description"/>
              <Item Value="PastDue"/>
            </AttrNames>
            <Accessors>
              <Item Value="TaskUser"/>
            </Accessors>
          </nodeDefinition>
          <nodeDefinition DefName="sample.common.publicModel.components.view.TaskUserVO"
                          Name="Task11">
            <AttrNames>
              <Item Value="ListName"/>
              <Item Value="PersonId"/>
              <Item Value="UserRole"/>
            </AttrNames>
          </nodeDefinition>
        </tree>
    Thanks,
    Srini

    Trying out with
    <af:iterator id="i1" rows="2" var="assigRow"  value="#{row.children}">
    Will keep the thread posted on my progress. Meanwhile, any suggestions welcome .
    Another way I could think of achieving this is to not use a UI iterator and instead get the value for my outputText using a bean method where I could get the present row of the tree and get the children and concatenate the Assignee names and return. But UI iterator should be a better way to do this if possible. So still exploring.

  • Iterate Through Lists Instead of Document Libraries, Or both

    System Info: SharePoint 2010 Enterprise w DEC 2013 CU. 2 WFEs (load balanced), App Server, SSRS Server, Dedicated CA Server (All running Win 2k8 R2).
    Background:I have a large (5,000 user) application that is completely customized on top of SP2010. I am the admin, and have been on the team for many years. Previously, we had a development team,
    but client has scaled costs back, and now its just me on the technical side. We have a Web app that houses multiple Site Collections, and each site collection has various subsites.
    My Problem: We have increased the LVT to 10k items (system has plenty of HP, although we do see performance degradation). Each subsite in the Site Collection holds data specific to an organization
    wtihin the Line of Business. There are two lists that frequently approach the 10k mark, and we have mitigation steps in place (essentially, we just create a new SubSite for them once they reach 10k). What I need is a single script that will traverse ALL subsites
    and return a count of their lists, perhaps I can work a couple of if statements in there to have specific data written to a SP List (if count is greater than 5000), and other wise everything gets written to the output file.
    I am trying to iterate through all lists and return a count of folders + items ... The script below works just fine, but it goes through Document Libraries only (per the baseType eq tag).
    I've tried changing baseType from DocumentLibrary to GenericList, but I continually get an error.
    I've also removed the where baseType = DocLib clause completely, and this has the desired results (all lists and doclibs are listed), except the 'WebUrl' field in the csv output is blank.
    Any thoughts on how I can make a small tweak to this script to get my desired results?
    Start-SPAssignment -Global
    $OutputFile ="D:\folder\DocCount3.csv"
    $results = @()
    $webApps = Get-SPWebApplication http://WebAppURL
    foreach($webApp in $webApps)
    foreach($siteColl in $webApp.Sites)
    foreach($web in $siteColl.AllWebs)
    $webUrl = $web.url
    $docLibs = $web.Lists | Where-Object {$_.baseType -eq "DocumentLibrary"}
    $docLibs | Add-Member -MemberType ScriptProperty -Name WebUrl -Value {$webUrl}
    $results += ($docLibs | Select-Object -Property WebUrl, Title, ItemCount)
    $results | Export-Csv -Path $OutputFile -NoTypeInformation
    Stop-SPAssignment –Global

    You guys won't believe this ... But, the script actually works as intended if I change the baseType tag to "GenericList"... I had been getting errors (about 14 of them) through PowerShell and
    assuming the script didn't process, but after looking at the output CSV, it seems that everything worked properly. I think the 14 errors MAY have been corrupted sites (or something?) as it gives me NullValueNotAllowed when trying to "Add-Member" and points
    to $WebUrl as being null.
    Next up -- working on getting this script to write specific objects to a SP list!

  • Iterate through list

    i have a list and i want to iterate through the list and get the names of the classes present in that..
    i have the following code
    Iterator it= list.iterator();
    String value;
    while(it.hasNext())
         Object obj= it.next();
         Class cls= obj.getClass();
         value = cls.getName();
    now if i want to check whether a class called test is present in that list how to do that...pls help

    mgv wrote:
    i have a list and i want to iterate through the list and get the names of the classes present in that..
    i have the following code
    Iterator it= list.iterator();
    String value;
    while(it.hasNext())
         Object obj= it.next();
         Class cls= obj.getClass();
         value = cls.getName();
    now if i want to check whether a class called test is present in that list how to do that...pls help
    while(it.hasNext()){
    Object obj = it.next();
    if(obj instanceof test){
        //do something
    }

  • What are the algorithem and container to be used for this problem?

    Say I have a class with the following properties:
    groupMonth //String (jan,feb,mar�)
    accumulatedLasyYear //double
    accumulatedThisYear //double
    What will be the best container/algorithm to use for objects from the class above so I can have them sorted by month (I know it�s a string) AND GROUP the months together (and the accumulated as well)
    Example:
    Jan 4 8
    Feb 2 3
    Mar 5 2
    Jan 3 5
    Feb 4 2
    Mar 9 3
    The output should be:
    Jan 7 13 //(4+3, 8+5)
    Feb 6 5
    Mar 14 5
    Thanks for any thought�

    I'd suggest a java.util.Map<String, Set<WhateverClassYouveDefined>>. The keys are the year, the values are Sets containing all objects of that year. Iterate through your list of objects and group them into the right set using the map.
    Then I'd suggest looping through the keys to get each month's worth. Since you know what all the keys will be in advance, and there's only twelve of them, create an array of the twelve month strings. Loop through that array, and for each value grab the corresponding Set from the map.
    Then for each set you get, iterate through its contents, get the values, and add them.
    Then just print the month and the sums of values from the set, and go on to the next month.

  • How to make List.contains(Object) work when you write your own .equals func

    I have a list of objcts of a class defined by me. I want to use the List.contains(String name) function to tell me if it contains an object of that name. I have overriden the .equals function as shown in [1]. I then use the code at [2] to to test it, with a bit of debugger output as shown in [3]. It is not working, my overriden method is not getting called by List.contains(String name).
    Can anyone tell me how to get this to work?
    [1]     @Override public boolean equals(Object esId) {
            if(esId.getClass().isAssignableFrom(String.class)) {
                System.out.println("object name " + this.eslimId + " compare to " + esId + " = " + this.eslimId.equals(esId));
                return this.eslimId.equals(esId);
            } else {
                System.out.println("wrong class");
                return super.equals(esId);
        }[2] graphics.getProcedures() returns private List<ProcedureGraphicSet> procedures;
    System.out.println( " graphics.getProcedures().get(0).equals(\"ESLIM_009\")= " + graphics.getProcedures().get(0).equals("ESLIM_009"));
    System.out.println( " graphics.getProcedures().contains(\"ESLIM_009\")= " + graphics.getProcedures().contains("ESLIM_009"));[3]
    object name ESLIM_009 compare to ESLIM_009 = true
    graphics.getProcedures().get(0).equals("ESLIM_009")= true
    graphics.getProcedures().contains("ESLIM_009")= false

    This is a gross violation of the contract for the equals method, and you are basically getting bitten by that. The equals method must be symmetric, meaning this must hold for all objects A and B:
    A.equals(B) == B.equals(A)This does not hold for your equals method because for any string A and custom object B:
    A.equals(B) == falseAnd, apparently, the List.contains() method is choosing to compare objects that way.
    You must iterate through the list and check the names yourself, or use some sort of functional package which provides a List.contains() type method which takes a Predicate object of some sort.
    Edited by: jtahlborn on Feb 11, 2008 11:03 AM
    Edited by: jtahlborn on Feb 11, 2008 11:03 AM

  • "Economizing" in a list of maps with identical keys (like a database table)

    Hi there!:
    I've been checking this forum for information about something like what I state in the title of this message, but haven't found such a specific case. I'm commenting my doubt below.
    I'm working with a list of maps whose keys are exactly the same in all them (they're of type String). Indeed it could be considered an extrapolation of a database table: The list contains maps which act as rows, and every map contains keys and values which represent column names and values.
    However, this means to repeat the same key values on every map and this spends memory. Right, maybe it's not such a big spent, but since the list can contains thousands of maps, I think that it would be better to choose a more "economical" way to achieve the same result.
    I had thought about building a class which stored everything as a list of lists and, internally, it mapped that String keys with the corresponding Integer indexes of every list. But then I realized that maybe I was re-inventing the wheel, because it's very probable that someone has already made that. Maybe is there a class on the Core API which allows that?
    Thank you very much for your help.

    Well, after re-reading the Java tutorial which is located in the Sun website I've came to a conclusion which I should have before, when I thought about using StringBuffers as keys of the maps instead of Strings.
    I'm so used to build Strings using literals instead of the "new String ()" constructor (just as everyone) that I had forgotten that, as it happens with any kind of object but not the primary data types, Strings are not passed to the methods by value, but by reference. The fact of them being immutable made me think that they were passed by value.
    Apart of that, my problem also was that using literals I was creating different String objects every time, despite the fact that they were equal about their content (making 400 different keys called "name" for example)
    In other words, I was doing something like this:
    // It makes a list of maps which will contain maps of boy's personal data (as if they were "rows" in a table).
    List <Map <String, Object>> listData = new ArrayList <Map <String, Object>> (listBoy.size ());
    // It loops over a list of Boy objects, obtained using EJB.
    for (Boy boy : listBoy) {
         // It makes a new map containing only the information which I'm interested on from the Boy object.
         Map <String, Object> map = new HashMap <String, Object> (2);
         map.put ("name", boy.getName ());
         map.put ("surname", boy.getSurname ());
         // It adds the map to the list of data.
         listData.add (map);
    }Well, the "problem" here (being too demanding, but I'm :P ) is that I was adding all the time new Strings objects as keys in every map. The key "name" in the first map was different from "name" in the second one and so on.
    I guess that my knowledge got messed at certain point and thought that it was impossible to use exactly the same String object in different maps (the reference, not the same value!). Thus, my idea of using StringBuffers instead.
    But thinking about it carefully, Why not to do this?:
    List <Map <String, Object>> listData = new ArrayList <Map <String, Object>> (listBoy.size ());
    // It makes the necessary String keys previously, instead of using literals on every loop later.
    String name = "name";
    String surname = "surname";
    for (Boy boy : listBoy) {
         // It uses references (pointers) to the same String keys, instead of new ones every time.
         Map <String, Object> map = new HashMap <String, Object> (2);
         map.put (name, boy.getName ());
         map.put (surname, boy.getSurname ());
         listData.add (map);
    }Unfortunately, the "hasCode" method on String is overloaded and instead of returning the typical hash code based on the single ID of the object in memory, it returns one based on its content. That way I can't make sure that the "name" key in one map refers to the same object in memory than another one. I know, I know. The common sense and the Java documentation confirm that, but had loved having an empiric way to demonstrate it.
    I guess that using "javap" and disassembling the generated bytecode is the only way to make sure that it's that way.
    I believe that it's solved now :) (if no one tells me the contrary). I still am mad at myself for thinking that Strings were passed by value. Thinking about it now it had no sense!
    dannyyates: It's curious because re-reading every answer I think that you maybe were pointing to this solution already. But the sentence "you put the +same+ string" was a little ambiguous for me and thought that you meant putting the same String as "putting the same text" (which I already was doing), not the same object reference (in other words, using a common variable). I wish we could have continued discussing that in depth. Thanks a lot for your help anyway :) .

  • Get list items using spservices for sharepoint 2013

    Hi,
    I have a requirement like below.
    I have 2 sharepoint custom list with some columns.
    List1:listA
    List2:listB
    Now when i open the listB new item form i want some of the field values from listA should auto populate in Textboxes of listB new form.
    Is there any ways to implement this?
    Regards,
    Poovi

    Hi Poovi,
    You can achieve this using jQuery to get the SharePoint list items. Refer the below articles. It has explained how to get list items using jQuery and auto populate a text-box from a list item as a source.
    You can put this code in list forms through SharePoint Designer. The articles explain about auto populating text box of web part but similarly you can implement it for list form, because nevertheless the text boxes are same.
    http://www.c-sharpcorner.com/UploadFile/sagarp/sharepoint-2010-jquery-autocomplete-textbox-containing-list/
    http://tomvangaever.be/blogv2/2011/07/sharepoint-2010-autocomplete-with-list-items/
    Please remember to click 'Mark as Answer' if the reply answers your query or 'Upvote' if it helps you.

  • How to customize a List object to contain line items other than String

    I'd like to create a List that contains line items with the following form:
    check box followed by a string followed by a button.
    I'd like the list to be backed by an object array that has a similar form:
    boolean, String, boolean
    which define if the item is checked, it's title, and whether or not to display the button.
    So I'd like to have code something like this:
    // ten items in this lists
    MyList myList = new MyList(10);
    // first item
    MyObject myObject = new MyObject(false, "Item 1", true);
    myList.add(myObject);
    // add the rest of the items...I can't use Swing, I only have AWT available in a J2ME environment.
    Where do I start?
    Can I do this with List?
    I've looked at GridBagLayout but I'm unfamiliar with it. Would a GridBagLayout work?
    Do I need to create a custom control from scratch (based on Panel or ScrollPane, for example) to accomplish this?
    Thanks,
    Nick.

    List only takes Strings. Here's an possibility with GridBagLayout:
    import java.awt.*;
    import java.awt.event.*;
    public class ListTest implements ActionListener
        Object[][] data =
            { Boolean.TRUE,  "John Ericsen",   Boolean.TRUE  },
            { Boolean.FALSE, "Heidi Pall",     Boolean.TRUE  },
            { Boolean.FALSE, "Gregg Fletcher", Boolean.FALSE },
            { Boolean.TRUE,  "Pieter Gaynor",  Boolean.TRUE  },
            { Boolean.TRUE,  "Janice Clarke",  Boolean.TRUE  },
            { Boolean.TRUE,  "May McClatchie", Boolean.FALSE },
            { Boolean.TRUE,  "Bill Horton",    Boolean.TRUE  },
            { Boolean.FALSE, "Helmet Krupp",   Boolean.TRUE  },
            { Boolean.FALSE, "Ian George",     Boolean.TRUE  },
            { Boolean.TRUE,  "Jill Smythe",    Boolean.FALSE }
        public void actionPerformed(ActionEvent e)
            Button button = (Button)e.getSource();
            String ac = button.getActionCommand();
            System.out.println("ac = " + ac);
        private Panel getPanel()
            Panel panel = new Panel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(2,2,2,2);
            //gbc.weightx = 1.0;         // horizontal dispersion
            //gbc.weighty = 1.0;         // vertical dispersion
            for(int j = 0; j < data.length; j++)
                Checkbox cb = new Checkbox("", ((Boolean)data[j][0]).booleanValue());
                gbc.gridwidth = 1;
                panel.add(cb, gbc);
                gbc.gridwidth = GridBagConstraints.RELATIVE;
                gbc.anchor = GridBagConstraints.WEST;
                panel.add(new Label((String)data[j][1]), gbc);
                gbc.anchor = GridBagConstraints.CENTER;
                gbc.gridwidth = GridBagConstraints.REMAINDER;
                if(((Boolean)data[j][2]).booleanValue())
                    Button b = new Button("call");
                    b.setActionCommand((String)data[j][1]);
                    b.addActionListener(this);
                    panel.add(b, gbc);
                else
                    panel.add(new Label("  "), gbc);
            return panel;
        private Panel getList()
            Panel child = getPanel();
            ScrollPane scrollPane = new ScrollPane()
                public Dimension getPreferredSize()
                    return new Dimension(200, 125);
            scrollPane.add(child);
            Panel panel = new Panel(new GridBagLayout());
            panel.add(scrollPane, new GridBagConstraints());
            return panel;
        private static WindowListener closer = new WindowAdapter()
            public void windowClosing(WindowEvent e)
                System.exit(0);
        public static void main(String[] args)
            Frame f = new Frame();
            f.addWindowListener(closer);
            f.add(new ListTest().getList());
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    }

  • Filter SharePoint list items using CAML query as same as Like operator in SQL Server.

    Hi ,
    I have filtered SharePoint list items based on Name using CAML query <Contains> . Now I have a new requirement is to filter list items using Like operator in SQL. But Like operator is not in CAML.
    How do I filter list items using CAML as same as Like operator in SQL.
    Please let me know.
    Thanks in Advance.

    Did you try using <Contains>?
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/15766fd5-50d5-4884-82a1-29a1d5e38610/caml-query-like-operator?forum=sharepointdevelopmentlegacy
    --Cheers

Maybe you are looking for

  • How to get the first letter alone in Upper case?

    SQL*Plus: Release 9.2.0.1.0 - Production on Thu Jan 15 11:13:44 2009 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production With the Partitioning,

  • Scrolling/Sliding content in flash

    Hi, I'm looking for tutorials that  show how to create scrolling content in flash, but instead of an auto  scroll, I would like to click and drag the content. Similar to the link below. http://www.thisisgrow.com/archive/photosmart/en_us/#/products. T

  • InDesign CC crashing on Startup

    Hi all, InDesign CC is always crashing on me now when I start it up. I can't work out what's up. It's always at the 'Executing startup services-' stage. I renamed my preferences to see if this helped, but it created a new set upon opening and then cr

  • Only Right Headphone Works

    It started almost right after I listened to a song where there was a part where all of the noise would go from left and then right. It was supposed to do that, but then, within the next 10-15 minutes, the left one stopped playing any music at all. I

  • GPS is V E R Y inacurate!!! E75

    Hello all users of NOKIA GPS! Here I am with my problem... I have brand new NOKIA E75 When I start GPS, navigation shows my position 10-15 meters away from my real place, though I am freezed on one sertain place (without moving) for several minutes.