You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by rora <te...@go2.pl> on 2009/03/25 13:35:59 UTC

Repeater component with dynamic column list

Hello,
my goal is to display a table with dynamic number of columns (and of course
rows) based on my EntryData class.

ArrayList<EntryData> entries = ...;

public class EntryData implements Serializable
{
    private String                     entryID;
    private ArrayList<FieldData> entryFields;
[...]
}

where

public class FieldData implements Serializable
{
    private int       fieldId;
    private String   fieldLabel;
    private String   fieldValue;
[...]
}

I would like to have a table presenting entryID and values of all the fields
for each entry on the list.

Entry ID              | entryFields[0].fieldLabel                 | ... |
entryFields[x].fieldLabel
------------------------------------------------------------------------------------------------
entries[0].entryID | entries[0].entryFields[0].fieldValue  | ... |
entries[0].entryFields[x].fieldValue
...
entries[y].entryID | entries[y].entryFields[x].fieldValue  | ... |
entries[y].entryFields[x].fieldValue

I am not really experienced in Wicket and tried to find some Repeater class
example to use it as a base for building my own solution. Unfortunately I
didn't find anything that suits my needs.
I would like to know if it would be possible at all to use one of the
repeater control family member to display such data structure. I'll
appreciate any help and sample code.

Kind regards
R
-- 
View this message in context: http://www.nabble.com/Repeater-component-with-dynamic-column-list-tp22700806p22700806.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Repeater component with dynamic column list

Posted by rora <te...@go2.pl>.
 
%-O
I've spent a lot of time trying to figure out what's wrong with code and
markup but didn't notice this typo.

Thanks Martijn



You might want to spell wicket correctly in your markup. wikcet is not
the valid xmlns prefix :)

Martijn

-- 
View this message in context: http://www.nabble.com/Repeater-component-with-dynamic-column-list-tp22700806p22717153.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Repeater component with dynamic column list

Posted by Martijn Dashorst <ma...@gmail.com>.
You might want to spell wicket correctly in your markup. wikcet is not
the valid xmlns prefix :)

Martijn

On Wed, Mar 25, 2009 at 9:00 PM, rora <te...@go2.pl> wrote:
>
> Hi Janos,
> I did what you advised me to do but got the following exception (in this
> case I used a list of 3 entries with 3 fields):
> Unexpected RuntimeException
>
> WicketMessage: The component(s) below failed to render. A common problem is
> that you have added a component in code but forgot to reference it in the
> markup (thus the component will never be rendered).
>
> 1. [MarkupContainer [Component id = cell]]
> 2. [Component id = 1]
> 3. [Component id = 2]
> 4. [Component id = 3]
> 5. [Component id = 4]
> 6. [MarkupContainer [Component id = cell]]
> 7. [Component id = 1]
> 8. [Component id = 2]
> 9. [Component id = 3]
> 10. [Component id = 4]
>
> Root cause:
>
> org.apache.wicket.WicketRuntimeException: The component(s) below failed to
> render. A common problem is that you have added a component in code but
> forgot to reference it in the markup (thus the component will never be
> rendered).
>
> 1. [MarkupContainer [Component id = cell]]
> 2. [Component id = 1]
> 3. [Component id = 2]
> 4. [Component id = 3]
> 5. [Component id = 4]
> 6. [MarkupContainer [Component id = cell]]
> 7. [Component id = 1]
> 8. [Component id = 2]
> 9. [Component id = 3]
> 10. [Component id = 4]
>
> at org.apache.wicket.Page.checkRendering(Page.java:1121)
> at org.apache.wicket.Page.renderPage(Page.java:914)
> at
> org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.respond(BookmarkablePageRequestTarget.java:249)
> at
> org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:104)
> at
> org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1194)
> at org.apache.wicket.RequestCycle.step(RequestCycle.java:1265)
> at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1366)
> at org.apache.wicket.RequestCycle.request(RequestCycle.java:498)
> at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:444)
> at
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> at java.lang.Thread.run(Thread.java:619)
>
> //* File listings
> //*****************************************************************
> //EntryListPage.html
>
> <html xmlns:wicket>
>    <head>
>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
>        <title>EntryListPage</title>
>        <link rel="stylesheet" type="text/css" href="style.css"/>
>    </head>
>    <body>
>
>    </body>
> </html>
> //******************************************************************
> // EntryListPage.java
>
> public final class EntryListPage extends WebPage {
>    public EntryListPage() {
>        super ();
>
>        ArrayList<EntryData> entries = createSampleEntries();
>        EntryDataPanel entryDataPanel = new EntryDataPanel("entryDataPanel",
> entries);
>        add(entryDataPanel);
>        [...]
>    }
> }
> //******************************************************************
> // EntryDataPanel.html
> <html xmlns:wicket>
>    <head>
>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
>        <title>EntryDataPanel</title>
>    </head>
>    <body>
>        <wicket:panel>
>            <table border="1">
>            <tr>
>              <th>Entry Id</th>
>              <th wicket:id="heading">
>              </th>
>            </tr>
>            <tr wicket:id="row">
>              <td wikcet:id="cell">
>              </td>
>            </tr>
>            </table>
>        </wicket:panel>
>    </body>
> </html>
>
> //******************************************************************
> // EntryDataPanel.java
> public final class EntryDataPanel extends Panel
> {
>    public EntryDataPanel(String id, ArrayList<EntryData> entries)
>    {
>        super (id);
>
>        RepeatingView heading = new RepeatingView("heading");
>        for (FieldData fd : entries.get(0).entryFields)
>        {
>            heading.add(new Label(heading.newChildId(), fd.fieldLabel));
>        }
>        add(heading);
>        RepeatingView row = new RepeatingView("row");
>        add(row);
>        for (EntryData ed : entries)
>        {
>           WebMarkupContainer r = new WebMarkupContainer(row.newChildId());
>           RepeatingView cell = new RepeatingView("cell");
>           row.add(r);
>           r.add(cell);
>           cell.add(new Label(cell.newChildId(), ed.entryID));
>           for (FieldData fd : ed.entryFields)
>           {
>                cell.add(new Label(cell.newChildId(), fd.fieldValue));
>           }
>        }
>    }
> }
>
> I don't really know which component I am missing in the markup.
> I would be very grateful if you could help me once again, please.
> Regards
> R
>
>
>
>
>
> Janos Cserep-2 wrote:
>>
>>
>> I would use a custom panel component which would have the following
>> markup:
>> <tr>
>>    <th>Entry Id</th>
>>   <th wicket:id="heading">
>>   </th>
>> </tr>
>> <tr wicket:id="row">
>>   <td wikcet:id="cell>
>>   </td>
>> </tr>
>>
>> And the code:
>>
>> RepeatingView heading = new RepeatingView("heading");
>> for (FieldData fd : entries.get(0).entryFields) {
>>   heading.add(new Label(heading.newChildId(), fd.fieldLabel));
>> }
>> add(heading);
>> RepeatingView row = new RepeatingView("row");
>> add(row);
>> for (EntyData ed : entries) {
>>    WebMarkupContainer r = new WebMarkupContainer(row.newChildId());
>>    RepeatingView cell = new RepeatingView('cell");
>>    row.add(r);
>>    r.add(cell);
>>    cell.add(new Label(cell.newChildId(), ed.entryId));
>>    for (FieldData fd : ed.entryFields) {
>>      cell.add(new Label(cell.newChildId(), fd.fieldValue));
>>    }
>> }
>>
>> You need the WebMarkupContainer because it will get the same markup that
>> the
>> "row" repeatingview gets.
>>
>> This is quite basic, there is some room for optimization but I hope you
>> get
>> it.
>>
>> Janos
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Repeater-component-with-dynamic-column-list-tp22700806p22709785.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Repeater component with dynamic column list

Posted by rora <te...@go2.pl>.
Hi Janos,
I did what you advised me to do but got the following exception (in this
case I used a list of 3 entries with 3 fields):
Unexpected RuntimeException

WicketMessage: The component(s) below failed to render. A common problem is
that you have added a component in code but forgot to reference it in the
markup (thus the component will never be rendered).

1. [MarkupContainer [Component id = cell]]
2. [Component id = 1]
3. [Component id = 2]
4. [Component id = 3]
5. [Component id = 4]
6. [MarkupContainer [Component id = cell]]
7. [Component id = 1]
8. [Component id = 2]
9. [Component id = 3]
10. [Component id = 4]

Root cause:

org.apache.wicket.WicketRuntimeException: The component(s) below failed to
render. A common problem is that you have added a component in code but
forgot to reference it in the markup (thus the component will never be
rendered).

1. [MarkupContainer [Component id = cell]]
2. [Component id = 1]
3. [Component id = 2]
4. [Component id = 3]
5. [Component id = 4]
6. [MarkupContainer [Component id = cell]]
7. [Component id = 1]
8. [Component id = 2]
9. [Component id = 3]
10. [Component id = 4]

at org.apache.wicket.Page.checkRendering(Page.java:1121)
at org.apache.wicket.Page.renderPage(Page.java:914)
at
org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.respond(BookmarkablePageRequestTarget.java:249)
at
org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:104)
at
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1194)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1265)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1366)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:498)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:444)
at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)

//* File listings
//*****************************************************************
//EntryListPage.html

<html xmlns:wicket>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>EntryListPage</title>
        <link rel="stylesheet" type="text/css" href="style.css"/>
    </head>
    <body>
        
    </body>
</html>
//******************************************************************
// EntryListPage.java

public final class EntryListPage extends WebPage {
    public EntryListPage() {
        super ();

        ArrayList<EntryData> entries = createSampleEntries();
        EntryDataPanel entryDataPanel = new EntryDataPanel("entryDataPanel",
entries);
        add(entryDataPanel);
        [...]
    }
}
//******************************************************************
// EntryDataPanel.html
<html xmlns:wicket>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>EntryDataPanel</title>
    </head>
    <body>
        <wicket:panel>
            <table border="1">
            <tr>
              <th>Entry Id</th>
              <th wicket:id="heading">
              </th>
            </tr>
            <tr wicket:id="row">
              <td wikcet:id="cell">
              </td>
            </tr>
            </table>
        </wicket:panel>
    </body>
</html>

//******************************************************************
// EntryDataPanel.java
public final class EntryDataPanel extends Panel
{
    public EntryDataPanel(String id, ArrayList<EntryData> entries)
    {
        super (id);

        RepeatingView heading = new RepeatingView("heading");
        for (FieldData fd : entries.get(0).entryFields)
        {
            heading.add(new Label(heading.newChildId(), fd.fieldLabel));
        }
        add(heading);
        RepeatingView row = new RepeatingView("row");
        add(row);
        for (EntryData ed : entries)
        {
           WebMarkupContainer r = new WebMarkupContainer(row.newChildId());
           RepeatingView cell = new RepeatingView("cell");
           row.add(r);
           r.add(cell);
           cell.add(new Label(cell.newChildId(), ed.entryID));
           for (FieldData fd : ed.entryFields)
           {
                cell.add(new Label(cell.newChildId(), fd.fieldValue));
           }
        }
    }
}

I don't really know which component I am missing in the markup.
I would be very grateful if you could help me once again, please.
Regards
R





Janos Cserep-2 wrote:
> 
> 
> I would use a custom panel component which would have the following
> markup:
> <tr>
>    <th>Entry Id</th>
>   <th wicket:id="heading">
>   </th>
> </tr>
> <tr wicket:id="row">
>   <td wikcet:id="cell>
>   </td>
> </tr>
> 
> And the code:
> 
> RepeatingView heading = new RepeatingView("heading");
> for (FieldData fd : entries.get(0).entryFields) {
>   heading.add(new Label(heading.newChildId(), fd.fieldLabel));
> }
> add(heading);
> RepeatingView row = new RepeatingView("row");
> add(row);
> for (EntyData ed : entries) {
>    WebMarkupContainer r = new WebMarkupContainer(row.newChildId());
>    RepeatingView cell = new RepeatingView('cell");
>    row.add(r);
>    r.add(cell);
>    cell.add(new Label(cell.newChildId(), ed.entryId));
>    for (FieldData fd : ed.entryFields) {
>      cell.add(new Label(cell.newChildId(), fd.fieldValue));
>    }
> }
> 
> You need the WebMarkupContainer because it will get the same markup that
> the
> "row" repeatingview gets.
> 
> This is quite basic, there is some room for optimization but I hope you
> get
> it.
> 
> Janos
> 
> 

-- 
View this message in context: http://www.nabble.com/Repeater-component-with-dynamic-column-list-tp22700806p22709785.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Repeater component with dynamic column list

Posted by Cserep Janos <cs...@szeretgom.hu>.
>
> I would like to know if it would be possible at all to use one of the
> repeater control family member to display such data structure. I'll
> appreciate any help and sample code.
>

I would use a custom panel component which would have the following markup:
<tr>
   <th>Entry Id</th>
  <th wicket:id="heading">
  </th>
</tr>
<tr wicket:id="row">
  <td wikcet:id="cell>
  </td>
</tr>

And the code:

RepeatingView heading = new RepeatingView("heading");
for (FieldData fd : entries.get(0).entryFields) {
  heading.add(new Label(heading.newChildId(), fd.fieldLabel));
}
add(heading);
RepeatingView row = new RepeatingView("row");
add(row);
for (EntyData ed : entries) {
   WebMarkupContainer r = new WebMarkupContainer(row.newChildId());
   RepeatingView cell = new RepeatingView('cell");
   row.add(r);
   r.add(cell);
   cell.add(new Label(cell.newChildId(), ed.entryId));
   for (FieldData fd : ed.entryFields) {
     cell.add(new Label(cell.newChildId(), fd.fieldValue));
   }
}

You need the WebMarkupContainer because it will get the same markup that the
"row" repeatingview gets.

This is quite basic, there is some room for optimization but I hope you get
it.

Janos

Re: Repeater component with dynamic column list

Posted by Jonas <ba...@gmail.com>.
We've created a grid with dynamic columns similar to
org.apache.wicket.extensions.markup.html.repeater.data.grid.AbstractDataGridView,
except, of course, that the cell populators (the columns) don't come from
a fixed array, but from a (dynamic) list.

On Wed, Mar 25, 2009 at 1:35 PM, rora <te...@go2.pl> wrote:
>
> Hello,
> my goal is to display a table with dynamic number of columns (and of course
> rows) based on my EntryData class.
>
> ArrayList<EntryData> entries = ...;
>
> public class EntryData implements Serializable
> {
>    private String                     entryID;
>    private ArrayList<FieldData> entryFields;
> [...]
> }
>
> where
>
> public class FieldData implements Serializable
> {
>    private int       fieldId;
>    private String   fieldLabel;
>    private String   fieldValue;
> [...]
> }
>
> I would like to have a table presenting entryID and values of all the fields
> for each entry on the list.
>
> Entry ID              | entryFields[0].fieldLabel                 | ... |
> entryFields[x].fieldLabel
> ------------------------------------------------------------------------------------------------
> entries[0].entryID | entries[0].entryFields[0].fieldValue  | ... |
> entries[0].entryFields[x].fieldValue
> ...
> entries[y].entryID | entries[y].entryFields[x].fieldValue  | ... |
> entries[y].entryFields[x].fieldValue
>
> I am not really experienced in Wicket and tried to find some Repeater class
> example to use it as a base for building my own solution. Unfortunately I
> didn't find anything that suits my needs.
> I would like to know if it would be possible at all to use one of the
> repeater control family member to display such data structure. I'll
> appreciate any help and sample code.
>
> Kind regards
> R
> --
> View this message in context: http://www.nabble.com/Repeater-component-with-dynamic-column-list-tp22700806p22700806.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org