You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Eelco Hillenius <ee...@gmail.com> on 2007/12/02 04:10:41 UTC

Re: getObject() still called for Models in a when the content of the enclosure is not rendered?

That is very strange. It shouldn't be called, as the model object is
only requested when a component that is rendering requests it. Are you
really sure? Can you create a test case for this, or a quickstart
project that shows the problem and attach it to a JIRA issue please?

Eelco

On Nov 29, 2007 1:22 PM, Edvin Syse <ed...@sysedata.no> wrote:
> I'm wondering if this is expected behaviour:
>
> Create a <wicket:enclosure> element around to Labels, and let one of them be the child="" referenced in the enclosure tag. Let that Label
> return false on isVisible(). Even though the other Label isn't rendered, the getObject() method of it's model is still called. Do I need to
> override isVisible() on all components inside an enclosure to avoid this, or am I missing something?
>
> Markup:
>
> <wicket:enclosure child="label1">
>         <span wicket:id="label1">Label 1</span>
>         <span wicket:id="label2">Label 2</span>
> </wicket:enclosure>
>
>
> Java:
>
> add(new Label("label1") {
>         @Override
>         public boolean isVisible() {
>                 return false;
>         }
> });
>
> add(new Label("label2", new Model() {
>         @Override
>         public Object getObject() {
>                 System.out.println("Getting object of model 2");
>                 return "MODEL2 OBJECT";
>         }
>
> }));
>
> Everytime the page is loaded, I get the output to stdout from the getObject() method of label2. If I add a isVisible() to label2 which
> returns false, everything is ofcourse dandy.
>
> Sincerely,
> Edvin Syse
>
> ---------------------------------------------------------------------
> 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


Re: getObject() still called for Models in a when the content of the enclosure is not rendered?

Posted by Edvin Syse <ed...@sysedata.no>.
Done :)

https://issues.apache.org/jira/browse/WICKET-1200

-- Edvin

Eelco Hillenius skrev:
> Can you please open an issue for that and attach this code to it?
> 
> Thanks,
> 
> Eelco
> 
> On Dec 2, 2007 3:28 PM, Edvin Syse <ed...@sysedata.no> wrote:
>> I now did the following, and still got the error:
>>
>> mvn archetype:create -DarchetypeGroupId=org.apache.wicket \
>> -DarchetypeArtifactId=wicket-archetype-quickstart \
>> -DarchetypeVersion=1.3.0-rc1 \
>> -DgroupId=no.sysedata \
>> -DartifactId=enclosurebug
>>
>> mvn eclipse:eclipse
>>
>> /src/main/java/no/sysedata/HomePage.java:
>>
>> package no.sysedata;
>>
>> import org.apache.wicket.PageParameters;
>> import org.apache.wicket.markup.html.basic.Label;
>> import org.apache.wicket.markup.html.WebPage;
>> import org.apache.wicket.model.Model;
>>
>> public class HomePage extends WebPage {
>>         private static final long serialVersionUID = 1L;
>>
>>         public HomePage(final PageParameters parameters) {
>>                 add(new Label("label1") {
>>                         @Override public boolean isVisible() {
>>                                 return false;
>>                         }
>>                 });
>>
>>                 add(new Label("label2", new Model() {
>>                         @Override public Object getObject() {
>>                                 System.out.println("Getting object of model 2");
>>                                 return "MODEL2 OBJECT";
>>                         }
>>                 }));
>>         }
>> }
>>
>>
>> /src/main/java/no/sysedata/HomePage.html:
>>
>> <html>
>>      <head>
>>          <title>Wicket Enclosure Bug</title>
>>      </head>
>>      <body>
>>                 <wicket:enclosure child="label1">
>>                          <span wicket:id="label1">Label 1</span>
>>                          <span wicket:id="label2">Label 2</span>
>>                 </wicket:enclosure>
>>      </body>
>> </html>
>>
>> When I run it, I get the following on stdout:
>>
>> Getting object of model 2
>>
>>
>> And the rendered HTML when hitting the homepage is:
>>
>> <html>
>>      <head>
>>          <title>Wicket Enclosure Bug</title>
>>      </head>
>>      <body>
>>                 <wicket:enclosure child="label1"></wicket:enclosure>
>>      </body>
>> </html>
>>
>> If I add:
>>
>>         @Override protected void init() {
>>                 getMarkupSettings().setStripWicketTags(true);
>>         }
>>
>> to WicketApplication.java, the markup is:
>>
>> <html>
>>      <head>
>>          <title>Wicket Enclosure Bug</title>
>>      </head>
>>      <body>
>>
>>      </body>
>> </html>
>>
>> .. but the stdout is still the same.
>>
>> I'm very sorry if I'm missing something here and wasting everyones time, but to me it seems like a bug :)
>>
>> -- Edvin
>>
>> Eelco Hillenius skrev:
>>
>>> That is very strange. It shouldn't be called, as the model object is
>>> only requested when a component that is rendering requests it. Are you
>>> really sure? Can you create a test case for this, or a quickstart
>>> project that shows the problem and attach it to a JIRA issue please?
>>>
>>> Eelco
>>>
>>> On Nov 29, 2007 1:22 PM, Edvin Syse <ed...@sysedata.no> wrote:
>>>> I'm wondering if this is expected behaviour:
>>>>
>>>> Create a <wicket:enclosure> element around to Labels, and let one of them be the child="" referenced in the enclosure tag. Let that Label
>>>> return false on isVisible(). Even though the other Label isn't rendered, the getObject() method of it's model is still called. Do I need to
>>>> override isVisible() on all components inside an enclosure to avoid this, or am I missing something?
>>>>
>>>> Markup:
>>>>
>>>> <wicket:enclosure child="label1">
>>>>         <span wicket:id="label1">Label 1</span>
>>>>         <span wicket:id="label2">Label 2</span>
>>>> </wicket:enclosure>
>>>>
>>>>
>>>> Java:
>>>>
>>>> add(new Label("label1") {
>>>>         @Override
>>>>         public boolean isVisible() {
>>>>                 return false;
>>>>         }
>>>> });
>>>>
>>>> add(new Label("label2", new Model() {
>>>>         @Override
>>>>         public Object getObject() {
>>>>                 System.out.println("Getting object of model 2");
>>>>                 return "MODEL2 OBJECT";
>>>>         }
>>>>
>>>> }));
>>>>
>>>> Everytime the page is loaded, I get the output to stdout from the getObject() method of label2. If I add a isVisible() to label2 which
>>>> returns false, everything is ofcourse dandy.
>>>>
>>>> Sincerely,
>>>> Edvin Syse
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>
>> ---------------------------------------------------------------------
>> 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
> 

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


Re: getObject() still called for Models in a when the content of the enclosure is not rendered?

Posted by Eelco Hillenius <ee...@gmail.com>.
Can you please open an issue for that and attach this code to it?

Thanks,

Eelco

On Dec 2, 2007 3:28 PM, Edvin Syse <ed...@sysedata.no> wrote:
> I now did the following, and still got the error:
>
> mvn archetype:create -DarchetypeGroupId=org.apache.wicket \
> -DarchetypeArtifactId=wicket-archetype-quickstart \
> -DarchetypeVersion=1.3.0-rc1 \
> -DgroupId=no.sysedata \
> -DartifactId=enclosurebug
>
> mvn eclipse:eclipse
>
> /src/main/java/no/sysedata/HomePage.java:
>
> package no.sysedata;
>
> import org.apache.wicket.PageParameters;
> import org.apache.wicket.markup.html.basic.Label;
> import org.apache.wicket.markup.html.WebPage;
> import org.apache.wicket.model.Model;
>
> public class HomePage extends WebPage {
>         private static final long serialVersionUID = 1L;
>
>         public HomePage(final PageParameters parameters) {
>                 add(new Label("label1") {
>                         @Override public boolean isVisible() {
>                                 return false;
>                         }
>                 });
>
>                 add(new Label("label2", new Model() {
>                         @Override public Object getObject() {
>                                 System.out.println("Getting object of model 2");
>                                 return "MODEL2 OBJECT";
>                         }
>                 }));
>         }
> }
>
>
> /src/main/java/no/sysedata/HomePage.html:
>
> <html>
>      <head>
>          <title>Wicket Enclosure Bug</title>
>      </head>
>      <body>
>                 <wicket:enclosure child="label1">
>                          <span wicket:id="label1">Label 1</span>
>                          <span wicket:id="label2">Label 2</span>
>                 </wicket:enclosure>
>      </body>
> </html>
>
> When I run it, I get the following on stdout:
>
> Getting object of model 2
>
>
> And the rendered HTML when hitting the homepage is:
>
> <html>
>      <head>
>          <title>Wicket Enclosure Bug</title>
>      </head>
>      <body>
>                 <wicket:enclosure child="label1"></wicket:enclosure>
>      </body>
> </html>
>
> If I add:
>
>         @Override protected void init() {
>                 getMarkupSettings().setStripWicketTags(true);
>         }
>
> to WicketApplication.java, the markup is:
>
> <html>
>      <head>
>          <title>Wicket Enclosure Bug</title>
>      </head>
>      <body>
>
>      </body>
> </html>
>
> .. but the stdout is still the same.
>
> I'm very sorry if I'm missing something here and wasting everyones time, but to me it seems like a bug :)
>
> -- Edvin
>
> Eelco Hillenius skrev:
>
> > That is very strange. It shouldn't be called, as the model object is
> > only requested when a component that is rendering requests it. Are you
> > really sure? Can you create a test case for this, or a quickstart
> > project that shows the problem and attach it to a JIRA issue please?
> >
> > Eelco
> >
> > On Nov 29, 2007 1:22 PM, Edvin Syse <ed...@sysedata.no> wrote:
> >> I'm wondering if this is expected behaviour:
> >>
> >> Create a <wicket:enclosure> element around to Labels, and let one of them be the child="" referenced in the enclosure tag. Let that Label
> >> return false on isVisible(). Even though the other Label isn't rendered, the getObject() method of it's model is still called. Do I need to
> >> override isVisible() on all components inside an enclosure to avoid this, or am I missing something?
> >>
> >> Markup:
> >>
> >> <wicket:enclosure child="label1">
> >>         <span wicket:id="label1">Label 1</span>
> >>         <span wicket:id="label2">Label 2</span>
> >> </wicket:enclosure>
> >>
> >>
> >> Java:
> >>
> >> add(new Label("label1") {
> >>         @Override
> >>         public boolean isVisible() {
> >>                 return false;
> >>         }
> >> });
> >>
> >> add(new Label("label2", new Model() {
> >>         @Override
> >>         public Object getObject() {
> >>                 System.out.println("Getting object of model 2");
> >>                 return "MODEL2 OBJECT";
> >>         }
> >>
> >> }));
> >>
> >> Everytime the page is loaded, I get the output to stdout from the getObject() method of label2. If I add a isVisible() to label2 which
> >> returns false, everything is ofcourse dandy.
> >>
> >> Sincerely,
> >> Edvin Syse
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >
>
>
> ---------------------------------------------------------------------
> 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


Re: getObject() still called for Models in a when the content of the enclosure is not rendered?

Posted by Edvin Syse <ed...@sysedata.no>.
I now did the following, and still got the error:

mvn archetype:create -DarchetypeGroupId=org.apache.wicket \
-DarchetypeArtifactId=wicket-archetype-quickstart \
-DarchetypeVersion=1.3.0-rc1 \
-DgroupId=no.sysedata \
-DartifactId=enclosurebug

mvn eclipse:eclipse

/src/main/java/no/sysedata/HomePage.java:

package no.sysedata;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.model.Model;

public class HomePage extends WebPage {
	private static final long serialVersionUID = 1L;

	public HomePage(final PageParameters parameters) {
		add(new Label("label1") {
			@Override public boolean isVisible() {
				return false;
			}
		});

		add(new Label("label2", new Model() {
			@Override public Object getObject() {
				System.out.println("Getting object of model 2");
				return "MODEL2 OBJECT";
			}
		}));
	}
}


/src/main/java/no/sysedata/HomePage.html:

<html>
     <head>
         <title>Wicket Enclosure Bug</title>
     </head>
     <body>
		<wicket:enclosure child="label1">
		         <span wicket:id="label1">Label 1</span>
		         <span wicket:id="label2">Label 2</span>
		</wicket:enclosure>
     </body>
</html>

When I run it, I get the following on stdout:

Getting object of model 2


And the rendered HTML when hitting the homepage is:

<html>
     <head>
         <title>Wicket Enclosure Bug</title>
     </head>
     <body>
		<wicket:enclosure child="label1"></wicket:enclosure>
     </body>
</html>

If I add:

	@Override protected void init() {
		getMarkupSettings().setStripWicketTags(true);
	}

to WicketApplication.java, the markup is:

<html>
     <head>
         <title>Wicket Enclosure Bug</title>
     </head>
     <body>
		
     </body>
</html>

.. but the stdout is still the same.

I'm very sorry if I'm missing something here and wasting everyones time, but to me it seems like a bug :)

-- Edvin

Eelco Hillenius skrev:
> That is very strange. It shouldn't be called, as the model object is
> only requested when a component that is rendering requests it. Are you
> really sure? Can you create a test case for this, or a quickstart
> project that shows the problem and attach it to a JIRA issue please?
> 
> Eelco
> 
> On Nov 29, 2007 1:22 PM, Edvin Syse <ed...@sysedata.no> wrote:
>> I'm wondering if this is expected behaviour:
>>
>> Create a <wicket:enclosure> element around to Labels, and let one of them be the child="" referenced in the enclosure tag. Let that Label
>> return false on isVisible(). Even though the other Label isn't rendered, the getObject() method of it's model is still called. Do I need to
>> override isVisible() on all components inside an enclosure to avoid this, or am I missing something?
>>
>> Markup:
>>
>> <wicket:enclosure child="label1">
>>         <span wicket:id="label1">Label 1</span>
>>         <span wicket:id="label2">Label 2</span>
>> </wicket:enclosure>
>>
>>
>> Java:
>>
>> add(new Label("label1") {
>>         @Override
>>         public boolean isVisible() {
>>                 return false;
>>         }
>> });
>>
>> add(new Label("label2", new Model() {
>>         @Override
>>         public Object getObject() {
>>                 System.out.println("Getting object of model 2");
>>                 return "MODEL2 OBJECT";
>>         }
>>
>> }));
>>
>> Everytime the page is loaded, I get the output to stdout from the getObject() method of label2. If I add a isVisible() to label2 which
>> returns false, everything is ofcourse dandy.
>>
>> Sincerely,
>> Edvin Syse
>>
>> ---------------------------------------------------------------------
>> 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
> 


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