Hi,

read IAjaxRegionMarkupIdProvider's javadoc.

Regards
Sven

On 05/09/2014 08:34 PM, Nick Pratt wrote:
I have a Behavior attached to a WebMarkupContainer with a bind() method as
follows:

@Override
public void bind( Component component )
  {
this.boundComponent = component;

component.setOutputMarkupId( true );
  component.setOutputMarkupPlaceholderTag( true );

//------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------
component.add( new BorderBehaviour() );

//------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------

this.borderMarkupId = component.getMarkupId() + "_brd";
}

....
....
....
class BorderBehaviour extends Behavior
{
@Override
  public void beforeRender( Component component )
{
Response response = component.getResponse();

response.write( "<div id=\"" );
response.write( borderMarkupId ); // Generated from the bound component
above
  response.write( "\" class=\"popup\" style=\"display:none;\"><h1><span>" );
response.write( headerTextModel.getObject() );
  response.write( "</span><span class=\"close\"><a>X</a></span></h1>" );
}

@Override
public void afterRender( Component component )
{
  component.getResponse().write( "</div>" );
}
}


When a page is initially loaded, beforeRender() and afterRender() get
executed just fine.  If the user hits the browser reload button, everything
still works (these two functions get executed).  However, during an Ajax
triggered event, I end up with duplicate markup being appended to the bound
component (since these two methods above run again, but the Component
hierarchy isn't re-generated, thus multiple copies of the additional markup
are written to the stream).

I tried making the behavior temporary, and while that fixes the Ajax case,
it breaks in the "user-presses-reload-button" case - since the behavior,
now temporary, gets detached from the request after the initial render and
doesnt get rerun when the user requests a page that is already
generated/cached.

How can I make this work for all three cases -
1. Page load
2. Page reload (same page ID)
3. Ajax

I noticed that the response in (3) is an AbstractAjaxResponse - is the only
way to fix this to run an instanceof check on the response type or is there
an alternate way?

N



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

Reply via email to