I am in the process of attempting to rebuild our non-framework, completely homegrown web application as a Wicket application.  So, I am very new to the Wicket way and find myself struggling with different things such as proper page construction techniques for relatively complex data-enabled pages.  So far, I have been successful in getting a Wicket app running that resembles our existing app, just a lot cleaner.  I am having trouble implementing a GUI comcept that we use quite frequently in our current app.

In our current app, we typically have long pages of data fields available to the user, in an attempt to avoid information overload, we implemented "toggle sections" that hide the contents of a section of the page until the section header  or "twistee" is clicked, at which point the contents become visible.  This is relatively simple in our app, there are two divs, one for the header (name of section, usually one line) and the other for the contents.  The content div is "display:none" when the page loads and when the header is clicked to open, that attribute is removed.  Pretty simple.

I know that I could do the same think in the Wicket app, but it didn't seem to take advantage of Wicket's features.  So, I am seeking to create the described functionality in a more Wicket-minded way.  I am open to suggestions of how YOU would do it, but you'll find my idea below.  Mind  you, that my way doesn't work...yet.

My idea:
Create a panel called ToggleSectionPanel.  If would handle the look-n-feel of the toggle header as well as hold the content that should be shown/hidden.

Given a strutuce like this

WebPage
        ContentPanel
                ToggleSectionPanel (section 1)
                        SomeFieldsPanel
                        SomeOtherFieldsPanel
                ToggleSectionPanel (section 2)
                        EvenMoreFieldsPanel

ContetPanel code initialization snippet
        ToggleSectionPanel tsp = new ToggleSectionPanel("togPanel");
        tsp.setSectionTitle("Section 1");
        tsp.addPanel(new SomeFieldsPanel("panel1"));
        tsp.addPanel(new SomeOtherFieldsPanel("panel1"));
        add(tsp);
               
        tsp = new ToggleSectionPanel("togPanel2");
        tsp.setSectionTitle("Section 2");
        tsp.addPanel(new EvenMoreFieldsPanel("panel1"));
        add(tsp);

ToggleSectionPanel.html
        <wicket:panel>
                <table border="0" width="100%" cellspacing="0">
                        <tr>
                                <td width="20px">
                                        <img wicket:id="toggleImage" width="17" height="15" border="0" />
                                </td>
                                <td class="toggleSectionHeader">
                                        <span wicket:id="sectionTitle">[section title]</span>
                                </td>
                        </tr>
                </table>
                <div wicket:id="panels">
                </div>
        </wicket:panel>

I thought that I might use a ListView to simply write out the panels, but the problem I encountered was that I was adding a Panel in code (new SomeFieldsPanel("panel1")) but I wasn't referencing the id ("panel1") in the html because the listView's ListItems were named by the index.  So, then I thought I could just make a MarkupContainer that would spit out the Panels' markup, but that didn't work either.

public class PanelList extends WebMarkupContainer {
        /**
         * @see wicket.Component#onRender(wicket.markup.MarkupStream)
         */
        @SuppressWarnings("unchecked")
        protected void onRender(final MarkupStream markupStream) {
                final List<Panel> list = (List) getModelObject();

                // Save position in markup stream
                final int markupStart = markupStream.getCurrentIndex();

                if (list != null) {
                        for (Panel p : list) {
                                markupStream.setCurrentIndex(markupStart);
                                p.renderComponent(markupStream);
                        }
                }
        }

I got an error "No Markup found" and it referenced the Panel that was part of the List of Panels.

I know that there is a lot here and I hope that it is coherent, but if anyone can offer me some guidance, it would be MUCH appreciated.


Chuck Deal


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to