there are two ways to do it:
either use ajaxrequesttarget.appendjavascript() instead of behavior
or write a behavior that uses renderhead() to output the javascript
and override istemporary to return true - that way it is removed at
the end of the request.
-igor
On Sun, Mar 9, 2008 at 6:39 PM, atul singh <[EMAIL PROTECTED]> wrote:
> How can i write an ajax behaviour which does not have its own callback, but
> just appends javascript to an existing AjaxRequestTarget.
> I want this so that i can write a fading feed back panel, which will be
> added to AjaxRequestTarget of an ajax form submission.
>
> What I want is something like this::
> *the behaviour---*
> public class AjaxFadeBehaviour extends AbstractAjaxBehavior{
> private IModel fadingNeededIModel;
> public AjaxFadeBehaviour() {
> super();
> }
>
> /**
> * Use a boolean value wrapped in an IModel to know if fading effect is
> needed.
> * This can be useful in situations for example when info messages need
> to fade away while error messages need not.
> * @param fadingNeededIModel
> */
> public AjaxFadeBehaviour(IModel fadingNeededIModel) {
> super();
> this.fadingNeededIModel = fadingNeededIModel;
> }
>
> public void onRequest() {
> System.out.println("on request called");
> if(fadingNeededIModel!=null){
> if(Strings.isTrue((String) fadingNeededIModel.getObject()))
>
>
> ((AjaxRequestTarget)RequestCycle.get().getRequestTarget()).appendJavascript("new
> Effect.Fade($('"
> + getComponent().getMarkupId() + "'));");
> }
> }
> }
>
> *the feedback component ---
> *public class AjaxFadingFeedbackPanel extends FeedbackPanel{
>
> public AjaxFadingFeedbackPanel(String id, IFeedbackMessageFilter filter)
> {
> super(id, filter);
> setOutputMarkupId(true);
> final AbstractReadOnlyModel fadingNeededModel=new
> AbstractReadOnlyModel(){
> @Override
> public Object getObject() {
> return anyMessage(FeedbackMessage.INFO);
> }
> };
> add(new AjaxFadeBehaviour(fadingNeededModel));
> }
>
> public AjaxFadingFeedbackPanel(String id) {
> this(id,null);
> }
>
> }
>
> I am not able to achieve this because onRequest() does not get called for
> AjaxFadeBehaviour.
> I am confused about which class I should extend to achieve this??
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]