You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by simonm <si...@redbend.com> on 2008/12/02 18:15:07 UTC

WebMarkupContainer within WebMarkupContainer not updated when Ajax update

My WebPage consists of two WebMarkupContainer: one is the parent of the
other.
The two WebMarkupContainer are encapsulated within a div tag as the
following:
<div wicket:id="wmc1">		
	<div wicket:id="wmc2">
		<table cellpadding="0" cellspacing="5" class="filterBy">
                   ...
		</table>
	</div>
     
         ...
     
       <table>
           ...
       </table>
</div>

In Java file, I added wmc2 as a child of wmc1 ("wmc1.add(wmc2)" ) as the
following:
	final WebMarkupContainer wmc1 = new WebMarkupContainer("wmc1");
	wmc1.setOutputMarkupId( true );
        ...
	WebMarkupContainer wmc2 = new WebMarkupContainer("wmc2", new
SomeInnerModel());
	wmc2.setOutputMarkupId( true );
        wmc1.add(wmc2);

(

The problem: wmc1 is updates while Ajaxing it (wmc1 was added as a target
for some ajax component), while wmc2 not!!
I thought that wmc2 should be updated too since it is a child of a wmc1.
Even if I adding wmc2 to the target of an Ajax component (as done with wmc1)
- it is not updated!
The model attached to wmc2 is derived from LoadableDetachableModel and
implements the load() method.

I'm quite frustrated while making some works around that issue.
Does Wicket supports that behavior at all?
Any idea?

THANKS for ADVANCE!
 
-- 
View this message in context: http://www.nabble.com/WebMarkupContainer-within-WebMarkupContainer-not-updated-when-Ajax-update-tp20796182p20796182.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: WebMarkupContainer within WebMarkupContainer not updated when Ajax update

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Wed, 03 Dec 2008, simonm wrote:
> wmc2.add( new Label("new", ((ArrayList<Integer>)wmc2.getModelObject()).get(
> 4 ).toString()) );

That's the problem, your Labels never get new data.

Their models should be something like this

  new AbstractReadOnlyModel() {
      @Override
      public Object getObject() {
          List<Integer> integers = ((List<Integer>) wmc2.getModelObject());
	  return integers.get(4).toString();
      }
  }

so that they get evaluated dynamically. 

BTW, it would be a good idea to format and name your code 
more conventionally! And use a better data structure than an
indexed list of ints for your data.

> As you suggested, I used the WICKET AJAX DEBUG and I was wondering why wmc1
> enclosed within component id while wmc2 not:

That's because wmc1 was updated and wmc2 is inside it.

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

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


Re: WebMarkupContainer within WebMarkupContainer not updated when Ajax update

Posted by simonm <si...@redbend.com>.
Timo, Thanks a lot for your reply, regarding your answer I’m suspecting that
something is probably wrong with the Model of wmc2. I would like please to
show how did I implemented the Model of wmc2 and hopefully you’ll notice
something wrong over there:

final WebMarkupContainer wmc1= new WebMarkupContainer("wmc1");
wmc1.setOutputMarkupId( true );
…

WebMarkupContainer wmc2 = new WebMarkupContainer("wmc2", new
TrackSummeryModel());
wmc2.setOutputMarkupId( true );
wmc1.add( wmc2 );
		
wmc2.add( new Label("new", ((ArrayList<Integer>)wmc2.getModelObject()).get(
4 ).toString()) );
wmc2.add( new Label("running",
((ArrayList<Integer>)wmc2.getModelObject()).get( 0 ).toString()) );
wmc2.add( new Label("completed",
((ArrayList<Integer>)wmc2.getModelObject()).get( 3 ).toString()) );
wmc2.add( new Label("success",
((ArrayList<Integer>)wmc2.getModelObject()).get( 1 ).toString()) );
wmc2.add( new Label("errors",
((ArrayList<Integer>)wmc2.getModelObject()).get( 2 ).toString()) );
		
this.add (wmc1); //"this" extends wicket WebPage


…and wmc2 Model looks like the following:
public class TrackSummeryModel extends AbstractReadOnlyModel {
	private static final long serialVersionUID = -4460246538584276209L;
	@Override
	public Object getObject()
	{
		ArrayList<Integer> result = null;
		try {
			result = QueryDB.summerizeTracks();
		}
		catch ( Exception e ) {
			error( "Error while retrieving Track summery: " + e.getMessage() );
		}
		return result;	
	}
}

I expect that TrackSummeryModel should be called its getObject() method
while need rendering (wmc2 is a child of wmc1 and wmc1 was added to the
target of some Ajax component). 
The TrackSummeryModel:getObject() method is called only 5 times at the
construction of the page for each new Label I’m adding and then it stops
called for ever (BTW: wmc1 has a DataView component as a child and it
refresh via Ajax)
BTW: I attached the model’s labels such way since I’m dealing with
ArrayList<Integer> and not a simple POJO. Maybe I must create a POJO class
with 5 properties (new, running, etc) ?

Another thing:
As you suggested, I used the WICKET AJAX DEBUG and I was wondering why wmc1
enclosed within component id while wmc2 not:

...><component id="wmc1_16"  encoding="wicket1" ><![CDATA[<div id="
wmc1_16"> 
         
            <div id="wmc2_17"> 
                <table cellpadding="0" cellspacing="5" class="filterBy"> 
                    <tr> 
                        <td class="details">New:</td><td>0New: </td>   
                        <td class="details">Running:Running: </td><td>3</td>   
                        <td class="details">Completed:Completed:
</td><td>23</td>   
                        <td class="details">Success:Success: </td><td>0</td>   
                        <td class="details">Errors:Errors: </td><td>23</td> 
                    </tr>   
                </table> 
            </div>
...

Any idea? something?...:-( 



Timo Rantalaiho wrote:
> 
> On Tue, 02 Dec 2008, simonm wrote:
>> <div wicket:id="wmc1">		
>> 	<div wicket:id="wmc2">
> ...
>> The problem: wmc1 is updates while Ajaxing it (wmc1 was added as a target
>> for some ajax component), while wmc2 not!!
>> I thought that wmc2 should be updated too since it is a child of a wmc1.
> 
> Exactly. You can check out the exact behavior from the 
> Ajax debug console (visible when running with 
> -Dwicket.configuration=development ), but because updating 
> wmc1 with Ajax means replacing the corresponding div 
> entirely, it definitely replaces all of its contents as 
> well.
> 
> Most probably your problem is due to a model of wmc2 which 
> still makes it display old data on the next render.
> 
> Other possibility is an error in the Ajax update; that 
> should be visible in the Ajax debug console.
> 
> If you want others to investigate further, you should make 
> a quickstart that demonstrates the problem. It's also a good
> exercise as you'll probably solve this issue while preparing 
> the quickstart ;)
> 
> Best wishes,
> Timo
> 
> -- 
> Timo Rantalaiho           
> Reaktor Innovations Oy    <URL: http://www.ri.fi/ >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/WebMarkupContainer-within-WebMarkupContainer-not-updated-when-Ajax-update-tp20796182p20814413.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: WebMarkupContainer within WebMarkupContainer not updated when Ajax update

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Tue, 02 Dec 2008, simonm wrote:
> <div wicket:id="wmc1">		
> 	<div wicket:id="wmc2">
...
> The problem: wmc1 is updates while Ajaxing it (wmc1 was added as a target
> for some ajax component), while wmc2 not!!
> I thought that wmc2 should be updated too since it is a child of a wmc1.

Exactly. You can check out the exact behavior from the 
Ajax debug console (visible when running with 
-Dwicket.configuration=development ), but because updating 
wmc1 with Ajax means replacing the corresponding div 
entirely, it definitely replaces all of its contents as 
well.

Most probably your problem is due to a model of wmc2 which 
still makes it display old data on the next render.

Other possibility is an error in the Ajax update; that 
should be visible in the Ajax debug console.

If you want others to investigate further, you should make 
a quickstart that demonstrates the problem. It's also a good
exercise as you'll probably solve this issue while preparing 
the quickstart ;)

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

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