If anyone finds it useful enclosed is the code for an IComponentResolver which does what is described in this thread.

See the InheritPage as an example.

Christian

On Fri, 09 Dec 2005 11:36:03 +0100, Christian Essl <[EMAIL PROTECTED]> wrote:

Sorry the 'variable scoping' was misleading it is more like field scoping in Class hierarchies or the field/method-variable scoping within one class.

As I imagine this would work:

MyPage(){
add(new Label("hidden-by-cont1","hidden"));
add(new Label("global","can be everywhere")); //the intresting case

WebMarkupContainer cont1 = new WebMarkupContainer("cont1");
add(cont1);

cont1.add(new Label("hidden-by-cont1","cont1 hides"));
cont1.add(new Label("same-id","cont1 same-id"));

WebMarkupContainer cont2 = new WebMarkupContainer("cont2");
add(cont2);

cont2.add(new Label("same-id","cont2 same-id"));
}

<html>
<body>
  <span wicket:id="hidden-by-cont1">Prints: hidden</span>
  <div wicket:id="cont1">
    <span wicket:id="hidden-by-cont1">Prints: cont1 hides</span>
    <span wicket:id="same-id">Prints: cont1 same-id</span>
  </div>

  <div wicket:id="cont2">
    <span wicket:id="global">Prints: can be everywhere</span>
    <span wicket:id="same-id">Prints: cont2 same-id</span>
  </div>

So you can use the same ids in the same page. If the containing containers are not in the same hierarchy-line nothing changes. A comp with the same id hides the one of the parent-container with the same id.

On Fri, 9 Dec 2005 10:45:28 +0100, Johan Compagner <[EMAIL PROTECTED]> wrote:

better said is that id is then the same as a javascript/css id in the html
page.
It must be unqiue over a page itself.
But one thing, if you use listviews/repeaters or something like that you
will generated components with the same id.
But that is in youre case i think not a big problem because those will not
be moved around (i think)

johan


On 12/9/05, Christian Essl <[EMAIL PROTECTED]> wrote:

> I am against this. Since we have 1:1 we dont have id collissions, etc,
> etc.

If you restrict it to Page and Panel actually this would be quite the same as with variable scoping in Java. You would not have id collisions. Rather a component of a childcontainer with the same id would 'hide' the parent's component. And the html designer has anyway to be aware of all components
in the template-scope.

> It also breaks encapsulation, a component under this parent can behave
> this
> way, while under a different parent another way.

My current thought is that the component must implement
ICanRenderEverywhere{isRenderEveryWhere()}. So you can turn it off on the instance. Additional the component must be in a parent if you just put it in a specific childcontainer it can not be referenced from anywehere else
(like variable-scoping).

I think 99% of all labels or links are not dependent on the html hierarchy
(the wicket hierarchy remains). The only problem you could get is to
render it twice, which will cause an error.

> I dont want to open a can
> of worms here. Sure, sometimes it sucks that you have to change your
java
> code to accomodate such a small change but it makes things clear and
> simple,
> and as Juergen mentioned we can do a lot of error detection if we keep
> 1:1
> structure which is good.

Which error detection would not work anymore? Anyway I should first try to
implement it myself use it and will see.

Propably I am in a different situation than others. I'm lucky because the
html-designer I work with knows a lot of programming (to me he is a
javascript wizard - unfortunately always busy) so he is ready to
understand scoping, implications of hierarchies etc.

Christian

>
> -Igor
>
>
>
> On 12/8/05, Juergen Donnerstag <[EMAIL PROTECTED]> wrote:
>>
>> Actually some of the components work already like that, e.g.
>> HtmlHeaderContainer, BodyContainer and the autolink components.
>> But I'm not sure I'm in favour of changing it for all components. In
>> my opinion the current approach is easy and straight forward. There is
>> always a 1:1 match. Problems are easily found and fixed.
>> Idea: may be an apps setting could be used to enable/disable it
>> Idea: Traversing the hierachy up the tree should be stopped at Page and
>> Panels.
>>
>> Juergen
>>
>> On 12/8/05, Christian Essl <[EMAIL PROTECTED]> wrote:
>> > Hi,
>> >
>> > I like the way wicket handles templates. However when I worked with
it
>> the
>> > last few weeks I found one thing which could be realy improved:
>> >
>> > I had the case where the html-designer wanted to move a Label, which
>> was
>> > first inside a Form outside of the Form. To do that I had to change
>> the
>> > Java code. The the designer did not realy understand this, because
>> with
>> no
>> > other template-api he knows this is needed. It is also not realy the >> > concern of the programmer where the designer puts the label or link
>> and
>> > most often also panel.
>> >
>> > Maybe there could be an IComponentResolver which looks up the element
>> in
>> > the parent-containers and if it finds the element and the element
>> > implements say ICanRenderEverywhere the ComponentResolver just
renders
>> it.
>> >
>> > Christian
>> >
>> >
>> >
>> >
>> >
>> >
>> > ___________________________________________________________
>> > Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier
>> anmelden: http://mail.yahoo.de
>> >
>> >
>> >
>> > -------------------------------------------------------
>> > This SF.net email is sponsored by: Splunk Inc. Do you grep through
log
>> files
>> > for problems? Stop! Download the new AJAX search engine that makes
>> > searching your log files as easy as surfing the  web.  DOWNLOAD
>> SPLUNK!
>> > http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
>> > _______________________________________________
>> > Wicket-user mailing list
>> > Wicket-user@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/wicket-user
>> >
>>
>>
>> -------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
>> files
>> for problems?  Stop!  Download the new AJAX search engine that makes
>> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
>> http://ads.osdn.com/?ad_idv37&alloc_id865&opclick
>> _______________________________________________
>> Wicket-user mailing list
>> Wicket-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/wicket-user
>>



--
Christian Essl





___________________________________________________________
Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier
anmelden: http://mail.yahoo.de



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user







--
Christian Essl 

Attachment: inherit.jar
Description: temporary

Reply via email to