Well, it's a lot simpler than that.

Simply call rc.setMetaData( METAKEY_MYEVENTDATA, this );

Wicket handles the actual storage details (like storing your data in a MetaDataEntry array etc).
Nothing you need to think about :-)

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 13-2-2013 15:31, schreef Oscar Besga Arcauz:
Ok, it's a little complicated to create the metadata

If I'm rigth, the process is - for example when click on an AjaxLink into the 
page

1- Execute the method onClick of the AjaxLink
2- Send an event to all the components of the page (the page itself included, 
on first place, but not other pages ?),
    - The source of the event is the page itself
    - The type of broadcast is BREADTH
    - The payload is the AjaxRequestTarget (from the onclick method call)

/******** EXAMPLE OF DATA ************/
public class MyEventData {
static MetaDataKey<MyEventData> METAKEY_MYEVENTDATA = new MetaDataKey<MyEventData>(){}; String s = "";

     public MyEventData(){}
public MyEventData(String s) {
         this.s = s;
     }


public MetaDataKey<MyEventData> getWicketMetadataData(){
         // A little complicated
         MetaDataKey<MyEventData> key = new MetaDataKey<MyEventData>(){};
         MetaDataEntry<MyEventData> metaDataEntry = new 
MetaDataEntry<MyEventData>(key,this);
         MetaDataEntry<MyEventData>[] arrayMetaDataEntry =  new 
MetaDataEntry[]{metaDataEntry};
         key.set(arrayMetaDataEntry,this);
         return key;
     }
public void setIntoRequest(RequestCycle rc){
         rc.setMetaData(getWicketMetadataData(),this);
     }
public static MyEventData getFromRequest(RequestCycle rc){
         return rc.getMetaData(METAKEY_MYEVENTDATA);
     }
}


     > > > Oscar Besga Arcauz  < < <

-----Ernesto Reinaldo Barreiro <reier...@gmail.com> escribió: -----
Para: users@wicket.apache.org
De: Ernesto Reinaldo Barreiro <reier...@gmail.com>
Fecha: 13/02/2013  13:00
Asunto: Re: Request scoped variables, in ajaxrequesttarget

Hi Oscar,

On Wed, Feb 13, 2013 at 12:54 PM, Oscar Besga Arcauz <obe...@isdefe.es>wrote:

  Hi wickers !

I was wondering If there's any method to have request-scoped variables (
as HttpServletRequest.get/setAttributes )
Specially with AjaxRequestTarget, in AJAX calls.


Maybe RequestCycle#setMetaData might be useful for that.


Regards - Ernesto Reinaldo Barreiro
Antilia Soft
http://antiliasoft.com/ <http://antiliasoft.com/antilia>

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


Reply via email to