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??