All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kohsuke.stapler.json.SubmittedForm Maven / Gradle / Ivy

The newest version!
package org.kohsuke.stapler.json;

import net.sf.json.JSONObject;
import org.kohsuke.stapler.AnnotationHandler;
import org.kohsuke.stapler.InjectedParameter;
import org.kohsuke.stapler.StaplerRequest;

import javax.servlet.ServletException;
import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;

/**
 * Binds {@linkplain StaplerRequest#getSubmittedForm() the submitted form} to a parameter of a web-bound method.
 *
 * 

* On a web-bound doXyz method, use this annotation on a parameter to get the submitted * structured form content and inject it as {@link JSONObject}. * For example, * *

 * public HttpResponse doConfigSubmit(@SubmittedForm JSONObject o) {
 *   ...
 * }
 * 
* * @author Kohsuke Kawaguchi */ @Target(PARAMETER) @Retention(RUNTIME) @Documented @InjectedParameter(SubmittedForm.Handler.class) public @interface SubmittedForm { public static class Handler extends AnnotationHandler { @Override public Object parse(StaplerRequest request, Annotation a, Class type, String parameterName) throws ServletException { return request.getSubmittedForm(); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy