what you want is what we call a "bean panel", there have been a few gos at it in the wicket-stuff project. maybe someone who authored one can give details.

but i think you have the basic idea right:

create a panel to represent each type of form component: textfield,dropdown, etc. these panels are just wrappers around the existing form components that do nothing more then provide markup for them.

create a panel to host these different panels based on some definition. this is the bean panel. it has a simple loop that inserts these panels and possibly wraps them with some border for consistent look and feel. this border can display label/errors/whatever.

so really the only markup you need for the entire form becomes <span wicket:id="bean-panel"></span>

-Igor


On 8/16/06, Petr Sakar <[EMAIL PROTECTED]> wrote:
> What is your use case? Why do you want to do that?
>

Use case is
- to be able to generate lot of different forms (basically no grafic) with
fields which can be added removed dynamically
- maintain uniform look and feel (eg. not to define the html for
MyTextField on every form again and again - just define MyTextField.html
once and on form use add(new MyTextField("field1")) without need to add
<span wicket:id="field1"/> somewhere in form markup.

I could achieve this kind of behaviour with sligtly changed Loop and by
MyTextField extending Panel with added TextField. The problem is the panel
behaves only like wrapper without any real meaning and I can not override
easily TextField methods.

Basically I need to solve two things:
1. create component similar to loop without html markup, which renders its
children. Child does not have any tag (component does not have markup)
2. be able to provide markup for other components than panel (result of
point above) - eg. TextField

Thanx for any comments / hints
saki
saki

> Juergen
>
> On 8/16/06, Petr Sakar < [EMAIL PROTECTED]> wrote:
>> Hello,
>> can you please give some hint how to create component, which does not
>> nead
>> markup and to which I can add children ?
>> The intent is to be able create pages without need to create html for
>> such
>> pages at all - basically rendering driven by component structure and not
>> by markup.
>>
>> I've tryied it like following and it is working for me now, but most
>> probably there is better / more elegant way or some problem I do not
>> see.
>>
>>
>> Thank you in advance for any hints and comments.
>>
>> saki
>>
>>
>>
>> public class Panel extends WebMarkupContainer
>> {
>>
>> ...
>>
>>        /**
>>         * Renders this container.
>>         */
>>        protected void onRender(MarkupStream markupStream)
>>        {
>>                Response response = getResponse();
>>                boolean writeTag = !getRenderBodyOnly();
>>                if (writeTag) {
>>                        response.write(markupStream.get().toCharSequence());
>>                }
>>                layoutManager.startLayout(response);
>>
>>
>>                int currentIndex = markupStream.getCurrentIndex();
>>                int iteration = 0;
>>                // Iterate through children on this container
>>                for (Iterator iterator = iterator(); iterator.hasNext();)
>>                {
>>                        iteration ++;
>>                        // Get next child component
>>                        final Component component =
>> (Component)iterator.next();
>>
>>                        if (component == null)
>>                        {
>>                                throw new WicketRuntimeException(
>>                                                "Loop item is null.
>> Probably the number of
>> loop iterations were
>> changed between onBeginRequest and render time.");
>>                        }
>>                        layoutManager.startLayout(response, component);
>>
>>                        // Rewind to start of markup for kids
>>                         markupStream.setCurrentIndex(currentIndex);
>>                        if (component instanceof Panel) {
>>                                component.render(markupStream);
>>                        }       else if (component instanceof
>> WebMarkupContainerWithAssociatedMarkup) {
>>                                WebMarkupContainerWithAssociatedMarkup
>> markupContainer =
>> (WebMarkupContainerWithAssociatedMarkup) component;
>>                                markupContainer.renderAssociatedMarkup("panel",
>> "exceptionMessage");//(" saki exceptionMessage");
>>                        } else if (component instanceof MarkupContainer)
>> {
>>                                MarkupContainer markupContainer =
>> (MarkupContainer) component;
>>                                MarkupStream markupStream2 =
>> getApplication().getMarkupCache().getMarkupStream(markupContainer);
>>                                component.render(markupStream2);
>>                        } else {
>>                                component.render();
>>                        }
>>                        layoutManager.endLayout(response, component);
>>                }
>>                layoutManager.endLayout(response);
>>
>>
>>
>>                 markupStream.setCurrentIndex(currentIndex);
>>                while (!markupStream.atCloseTag())
>>                        markupStream.next();
>>                if (writeTag) {
>>                         response.write(markupStream.get().toCharSequence());
>>                }
>>        }
>>
>> ...
>>
>> }
>>
>>
>>
>> Notes:
>> - layoutManager is just just to write some markup around children (for
>> example table)
>> - html files must be created for components whose markup is normally in
>> parent component (eg. TextField, Form, ...).
>>
>>
>> -------------------------------------------------------------------------
>> 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-develop mailing list
>> Wicket-develop@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/wicket-develop
>>
>
> -------------------------------------------------------------------------
> 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-develop mailing list
> Wicket-develop@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-develop
>


-------------------------------------------------------------------------
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-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop

-------------------------------------------------------------------------
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-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to