You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Makundi (Commented) (JIRA)" <ji...@apache.org> on 2012/04/02 16:25:21 UTC
[jira] [Commented] (WICKET-2562) Allow Ajax FormSubmitting
component without default form processing (i.e., analogous to
IOnChangeListener)
[ https://issues.apache.org/jira/browse/WICKET-2562?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13244221#comment-13244221 ]
Martin Makundi commented on WICKET-2562:
----------------------------------------
I was discussing 1.4.x.. what branch can this AjaxFormSubmitBehavior.getDefaultProcessing() be found from?
> Allow Ajax FormSubmitting component without default form processing (i.e., analogous to IOnChangeListener)
> ----------------------------------------------------------------------------------------------------------
>
> Key: WICKET-2562
> URL: https://issues.apache.org/jira/browse/WICKET-2562
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Affects Versions: 1.4.3
> Reporter: Martin Makundi
> Priority: Minor
> Original Estimate: 5h
> Remaining Estimate: 5h
>
> Workaround exists but it is a reflection hack:
> public abstract class AjaxFormSubmittingChangeListenerBehavior extends
> AjaxFormSubmitBehavior {
> private final static Method hiddenFieldGetter;
> static {
> try {
> hiddenFieldGetter = Form.class.getDeclaredMethod("getHiddenFieldId");
> hiddenFieldGetter.setAccessible(true);
> } catch (Exception e) {
> throw new RuntimeException(e);
> }
> }
>
> /**
> * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#onBind()
> */
> @Override
> protected void onBind() {
> super.onBind();
> if (!(getComponent() instanceof IOnChangeListener))
> {
> throw new WicketRuntimeException("Behavior " + getClass().getName() +
> " can only be added to an instance of a IOnChangeListener");
> }
> }
> /**
> * @param event
> */
> public AjaxFormSubmittingChangeListenerBehavior(String event) {
> super(event);
> }
> /**
> * @see org.apache.wicket.ajax.form.AjaxFormSubmitBehavior#onError(org.apache.wicket.ajax.AjaxRequestTarget)
> */
> @Override
> protected void onError(AjaxRequestTarget target) {
> onSubmit(target);
> }
> /**
> * @see org.apache.wicket.ajax.form.AjaxFormSubmitBehavior#onEvent(org.apache.wicket.ajax.AjaxRequestTarget)
> */
> @Override
> protected void onEvent(AjaxRequestTarget target) {
> org.mortbay.util.MultiMap parameters = ((org.mortbay.jetty.Request) ((WebRequest) getComponent()
> .getRequest()).getHttpServletRequest()).getParameters();
> parameters.put(getHiddenFieldId(getForm()), getComponent().urlFor(IOnChangeListener.INTERFACE));
> super.onEvent(target);
> }
> /**
> * @param form
> * @return String
> */
> private String getHiddenFieldId(Form<?> form) {
> try {
> Form<?> root = form.getRootForm();
> return (String) hiddenFieldGetter.invoke(root);
> } catch (Exception e) {
> throw new RuntimeException(e);
> }
> }
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira