Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7838215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:02:22+00:00 2026-06-02T15:02:22+00:00

AID BID count1 count2 AID1 1 3 4 2 4 5 3 4 2

  • 0
AID      BID    count1  count2
AID1    1   3   4
            2   4   5
            3       4   2
AID2    4   6   10   
            5   2   4
            6   4   6
AID3    7   4   5
            8        9  4

THis is the table I am trying to display that is for every AID in ObjA display a list of ObjB s.

I want to display a Sortable data using Wicket DataTable or Listview .I have used the SortableData Provider and it works for simple Objects like

ObjA{
int a;
String b;
}

But I have an Object which has List of Objects within it as field as shown below.

ObjA{
Long aId;
List<ObjB> listObjB;
}

@magomi
Thank you for your response.This is the code and the corresponding Html files. I am using DataTables.
I am not sure how to render the items in the listObjBs (bID,count,count2) in the table for every aID.
What is the right way to add the columns for the listObjBs in the ObjA

***columns.add(new PropertyColumn<ObjA>(Model.of("B ID"), "ObjBCounts.bID",
                "ObjBCounts.BID"));
        columns.add(new PropertyColumn<ObjA>(Model.of(" Count"), "objBCounts.count"));
        columns.add(new PropertyColumn<ObjA>(Model.of("Count2”),"objBCounts.count2"));*** 

How do I sort on the column bID in the iterator method?

Public class HomePage extends Webpage
private static List<ObjB> listObjBs = Arrays.asList(
            new ObjB(15L,2,5),
            new ObjB(12L,7,10),
            new ObjB(13L,3,5),
            new ObjB(10L,6,5));

    private static List<ObjA> contacts = Arrays.asList( 
            new ObjA(1L,listObjBs),
            new ObjA(2L,listObjBs),
            new ObjA(3L,listObjBs),
            new ObjA(4L,listObjBs));

    public HomePage(final PageParameters parameters) {
        List<IColumn<ObjA>> columns = new ArrayList<IColumn<ObjA>>();
        columns.add(new PropertyColumn<ObjA>(Model.of("A ID"), "aID",
                "aID"));

        Public class HomePage extends Webpage
private static List<ObjB> listObjBs = Arrays.asList(
            new ObjB(15L,2,5),
            new ObjB(12L,7,10),
            new ObjB(13L,3,5),
            new ObjB(10L,6,5));

    private static List<ObjA> contacts = Arrays.asList( 
            new ObjA(1L,listObjBs),
            new ObjA(2L,listObjBs),
            new ObjA(3L,listObjBs),
            new ObjA(4L,listObjBs));

    public HomePage(final PageParameters parameters) {
        List<IColumn<ObjA>> columns = new ArrayList<IColumn<ObjA>>();
        columns.add(new PropertyColumn<ObjA>(Model.of("A ID"), "aID",
                "aID"));

        columns.add(new PropertyColumn<ObjA>(Model.of("B ID"), "ObjBCounts.bID",
                "ObjBCounts.BID"));
        columns.add(new PropertyColumn<ObjA>(Model.of(" Count"), "objBCounts.count"));
        columns.add(new PropertyColumn<ObjA>(Model.of("Count2”),"objBCounts.count2"));

        add(new DefaultDataTable<ObjA>("contacts", columns,
                new ContactsProvider(), 10));
    }
rivate static class ContactsProvider extends SortableDataProvider<ObjA> {
    public ContactsProvider() {
        setSort("aID", SortOrder.ASCENDING);
    }

    public Iterator<? extends ObjA> iterator(int first, int count) {
        List<ObjA> data = new ArrayList<ObjA>(contacts);
        Collections.sort(data, new Comparator<ObjA>() {

            public int compare(ObjA o1, ObjA o2) {
                int dir = getSort().isAscending() ? 1 : -1;

                if ("bID".equals(getSort().getProperty())) {
                    return dir * (o1.listObjB.get(0).getBID().compareTo(o2.listObjB.get(0).getBID()));
                } else {

                    return dir * (o1.getAID().compareTo(o2.getAID()));
                }
            }
        });
        return data.subList(first, Math.min(first + count, data.size()))
                .iterator();
    }

    public int size() {
        return contacts.size();
    }

    public IModel<ObjA> model(ObjA object) {
        return Model.of(object);
    }

}






<html>
<body>
<table border ="1" cellspacing = "1" wicket:id="contacts" class="contacts"></table>
</body>
</html>


        add(new DefaultDataTable<ObjA>("contacts", columns,
                new ContactsProvider(), 10));
    }
rivate static class ContactsProvider extends SortableDataProvider<ObjA> {
    public ContactsProvider() {
        setSort("aID", SortOrder.ASCENDING);
    }

    public Iterator<? extends ObjA> iterator(int first, int count) {
        List<ObjA> data = new ArrayList<ObjA>(contacts);
        Collections.sort(data, new Comparator<ObjA>() {

            public int compare(ObjA o1, ObjA o2) {
                int dir = getSort().isAscending() ? 1 : -1;

                if ("bID".equals(getSort().getProperty())) {
                    return dir * (o1.listObjB.get(0).getBID().compareTo(o2.listObjB.get(0).getBID()));
                } else {

                    return dir * (o1.getAID().compareTo(o2.getAID()));
                }
            }
        });
        return data.subList(first, Math.min(first + count, data.size()))
                .iterator();
    }

    public int size() {
        return contacts.size();
    }

    public IModel<ObjA> model(ObjA object) {
        return Model.of(object);
    }

}






<html>
<body>
<table border ="1" cellspacing = "1" wicket:id="contacts" class="contacts"></table>
</body>
</html>




ObjB{
Long bId;
int  count;
int count2;
}

It want to display data from ObjA which contains a list of objBs in a Sortable table
Could some one please help me with the wicket markup and and how to populate the columns.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:02:24+00:00Added an answer on June 2, 2026 at 3:02 pm

    I’m not quite sure but it looks like you are mixing ObjA and ObjB into one table in a way that is not possible. Is it right, you want to show a table of ObjA (at least this is indicated by your first column)? Or do you want to show a table of ObjB (as indicated by the second and third column)?

    As long as a table is backed by one list you cannot mix another list into this table.

    From my sight you have the following options:

    1. You can can have a table of ObjA and inside a table cell you can have a panel with a table of ObjB. But there is no sorting over all rows of ObjB of all ObjA.
    2. You can define some kind of DTO that has a object mixed from ObjA and ObjB. Something like this:

      class Data() {
      int objAId;
      int objBId;
      int count1;
      int count2;
      …
      }

    3. You can use a standard repeating view and implement the sorting into your own data provider.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write this SQL: SELECT a.a_id as aid, b.b_id as bid
Got this: Table a ID RelatedBs 1 NULL 2 NULL Table b AID ID
I have a data tables with this type of setup. Table A AID AName
I have this xml: <mappings> <mapping> <name iskey=true>234</name> <aid iskey=true>bmz</aid> <bid iskey=true>sim</bid> <data>GSSS</data> </mapping>
So I wrote this simple console app to aid in my question asking. What
I am trying to use vim properly - to aid me I've mapped my
I have an application that is supposed to aid my project in terms of
Just a curious question but is there any programs that can help/aid you when
I have two tables TableA aId aValue TableB bId aId bValue I want to
I have a very simple relation defined as follows ( aId and bId are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.