With Panel you know you always have the right markup so that is good. The disadvantage is that you'd then have to write panels for everything the ComponentFactory should be able to produce.

Maybe you could always return a container that overrides onComponentTag and set the tag's name according to the contained component. I don't know if this will even work, but you still have the disadvantage that you have to know the tagname for everything that could be produced / contained and do a lot of instanceof's. For some components this is even impossible, for example Link, which works on any html tag (for other tags than <a> it writes an onclick handler).

You can also do things with IMarkupResourceStreamProvider. That way the markup could dynamically be produced to be according to what you need.

Anyway, it quickly becomes complex. Igor's suggestion has the advantage that it's very clean and comprehensible. So if the ComponentFactory produces only a few components, write panels for them and your problem is solved.

Matthijs

Igor Vaynberg wrote:
wicket's default components do not mutate markup, so you cannot do
that. a better contract is eg

componentfactor { panel getpanel(string id); } eg ITab in extensions.
that way you know it will always work.

-igor

On Wed, Jun 18, 2008 at 7:39 PM, Dreamage <[EMAIL PROTECTED]> wrote:
Hi,

If for example I have the following panel:

<html xmlns:wicket>
<wicket:panel>
<div>
 < span wicket:id="genericComponent"/>
</div>
</wicket:panel>
</html>

And I want to insert a component at the place of span tag, but the component
is not instanciated by the panel ... it's provided by a factory. Here is the
code :

public class MyPanel extends Panel{
       public MyPanel(String id, ComponentFactory factory) {
               super(id);
               //Create a new generic component using a specific id
               add(factory.getComponent("genericComponent"));
       }

}

The problem is that if the factory returns a TextField, the placeholder tag
need to be a input tag instead of a span. Is there a generic wicket tag that
could allow me to indicate where a component goes without binding it to a
specific tag ? If not, can this be done another way ?

Thanks
--
View this message in context: 
http://www.nabble.com/Generic-component-placeholder-tp17996229p17996229.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--
Matthijs Wensveen
Func. Internet Integration
W http://www.func.nl
T +31 20 4230000
F +31 20 4223500

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to