Java源码示例:org.apache.wicket.ajax.attributes.IAjaxCallListener
示例1
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
IAjaxCallListener listener = new AjaxCallListener() {
@Override
public CharSequence getPrecondition(Component component) {
//this javascript code evaluates wether an ajaxcall is necessary.
//Here only by keyocdes for F9 and F10
return "var keycode = Wicket.Event.keyCode(attrs.event);" +
"if ((keycode == 112) || (keycode == 113) || (keycode == 114) || (keycode == 115))" +
" return true;" +
"else" +
" return false;";
}
};
attributes.getAjaxCallListeners().add(listener);
//Append the pressed keycode to the ajaxrequest
attributes.getDynamicExtraParameters()
.add("var eventKeycode = Wicket.Event.keyCode(attrs.event);" +
"return {keycode: eventKeycode};");
//whithout setting, no keyboard events will reach any inputfield
attributes.setPreventDefault(true);
}
示例2
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
IAjaxCallListener listener = new AjaxCallListener() {
@Override
public CharSequence getPrecondition(Component component) {
//this javascript code evaluates wether an ajaxcall is necessary.
//Here only by keyocdes for F9 and F10
return "var keycode = Wicket.Event.keyCode(attrs.event);" +
"if ((keycode == 112) || (keycode == 113) || (keycode == 114) || (keycode == 115))" +
" return true;" +
"else" +
" return false;";
}
};
attributes.getAjaxCallListeners().add(listener);
//Append the pressed keycode to the ajaxrequest
attributes.getDynamicExtraParameters()
.add("var eventKeycode = Wicket.Event.keyCode(attrs.event);" +
"return {keycode: eventKeycode};");
//whithout setting, no keyboard events will reach any inputfield
attributes.setPreventDefault(true);
}
示例3
@Override
public CharSequence getBeforeHandler(Component component) {
StringBuffer mergedBeforeHandler = new StringBuffer();
for (IAjaxCallListener listener: listeners) {
CharSequence beforeHandler = listener.getBeforeHandler(component);
if (beforeHandler != null)
mergedBeforeHandler.append(beforeHandler);
}
if (mergedBeforeHandler.length() != 0)
return mergedBeforeHandler;
else
return null;
}
示例4
@Override
public CharSequence getPrecondition(Component component) {
StringBuffer mergedPrecondition = new StringBuffer();
for (IAjaxCallListener listener: listeners) {
CharSequence precondition = listener.getPrecondition(component);
if (precondition != null)
mergedPrecondition.append(precondition);
}
if (mergedPrecondition.length() != 0)
return mergedPrecondition;
else
return null;
}
示例5
@Override
public CharSequence getBeforeSendHandler(Component component) {
StringBuffer mergedBeforeSendHandler = new StringBuffer();
for (IAjaxCallListener listener: listeners) {
CharSequence beforeSendHandler = listener.getBeforeSendHandler(component);
if (beforeSendHandler != null)
mergedBeforeSendHandler.append(beforeSendHandler);
}
if (mergedBeforeSendHandler.length() != 0)
return mergedBeforeSendHandler;
else
return null;
}
示例6
@Override
public CharSequence getAfterHandler(Component component) {
StringBuffer mergedAfterHandler = new StringBuffer();
for (IAjaxCallListener listener: listeners) {
CharSequence afterHandler = listener.getAfterHandler(component);
if (afterHandler != null)
mergedAfterHandler.append(afterHandler);
}
if (mergedAfterHandler.length() != 0)
return mergedAfterHandler;
else
return null;
}
示例7
@Override
public CharSequence getSuccessHandler(Component component) {
StringBuffer mergedSuccessHandler = new StringBuffer();
for (IAjaxCallListener listener: listeners) {
CharSequence successHandler = listener.getSuccessHandler(component);
if (successHandler != null)
mergedSuccessHandler.append(successHandler);
}
if (mergedSuccessHandler.length() != 0)
return mergedSuccessHandler;
else
return null;
}
示例8
@Override
public CharSequence getFailureHandler(Component component) {
StringBuffer mergedFailureHandler = new StringBuffer();
for (IAjaxCallListener listener: listeners) {
CharSequence failureHandler = listener.getFailureHandler(component);
if (failureHandler != null)
mergedFailureHandler.append(failureHandler);
}
if (mergedFailureHandler.length() != 0)
return mergedFailureHandler;
else
return null;
}
示例9
@Override
public CharSequence getCompleteHandler(Component component) {
StringBuffer mergedCompleteHandler = new StringBuffer();
for (IAjaxCallListener listener: listeners) {
CharSequence completeHandler = listener.getCompleteHandler(component);
if (completeHandler != null)
mergedCompleteHandler.append(completeHandler);
}
if (mergedCompleteHandler.length() != 0)
return mergedCompleteHandler;
else
return null;
}
示例10
@Override
public void renderHead(Component component, IHeaderResponse response) {
for (IAjaxCallListener listener: listeners) {
if (listener instanceof IComponentAwareHeaderContributor) {
IComponentAwareHeaderContributor headerContributor = (IComponentAwareHeaderContributor) listener;
headerContributor.renderHead(component, response);
}
}
}
示例11
public CompositeAjaxCallListener(IAjaxCallListener... listeners) {
this.listeners = listeners;
}
示例12
protected IAjaxCallListener getAjaxCallListener()
{
return null;
}
示例13
protected IAjaxCallListener getAjaxCallListener()
{
return null;
}