Package com.sun.jersey.api.representation

Examples of com.sun.jersey.api.representation.Form


     * Test checks that a POST on "data" resource adds the submitted data to
     * the maintained map.
     */
    @Test
    public void testPostOnDataResource() {
        Form formData = new Form();
        formData.add("name", "testName");
        formData.add("value", "testValue");
        WebResource webResource = resource();
        ClientResponse response = webResource.path("data")
                .type(MediaType.APPLICATION_FORM_URLENCODED)
                .post(ClientResponse.class, formData);
        assertEquals(Response.Status.OK, response.getResponseStatus());
View Full Code Here


        Client c = Client.create();

        WebResource r = c.resource("http://portal.vivicloud.net/index.php/api/login_info");

        System.out.println("===== portal & trend integration =====");
        Form form = new Form();
        form.add("cookie", "myId");
        form.add("service", "大成大樓888");
        form.add("hash", "大成大樓888");

        ClientResponse response = r.type(MediaType.APPLICATION_FORM_URLENCODED).post(ClientResponse.class, form);
        System.out.println(response.getEntity(String.class));

View Full Code Here

    Contact contact = jaxbContact.getValue();
    System.out.println(contact.getId() + ": " + contact.getName());
  }
 
  public static void postForm(WebResource r, String id, String name) {
    Form form = new Form();
    form.add("id", id);
    form.add("name", name);
    ClientResponse response = r.type(MediaType.APPLICATION_FORM_URLENCODED)
                   .post(ClientResponse.class, form);
    System.out.println(response.getEntity(String.class));
  }
View Full Code Here

            Type genericType,
            Annotation annotations[],
            MediaType mediaType,
            MultivaluedMap<String, String> httpHeaders,
            InputStream entityStream) throws IOException {
        return readFrom(new Form(), mediaType, entityStream);
    }
View Full Code Here

        }
        request.setMethod(override);
        if (override.equals("GET")) {
            if (MediaTypes.typeEquals(MediaType.APPLICATION_FORM_URLENCODED_TYPE, request.getMediaType())) {
                UriBuilder ub = request.getRequestUriBuilder();
                Form f = request.getFormParameters();
                for (Map.Entry<String, List<String>> param : f.entrySet()) {
                    ub.queryParam(param.getKey(), param.getValue().toArray());
                }
                request.setUris(request.getBaseUri(), ub.build());
            }
        }
View Full Code Here

                in = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
                setEntityInputStream(in);
            }

            ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream) in;
            Form f = getEntity(Form.class);
            byteArrayInputStream.reset();
            return f;
        } else {
            return new Form();
        }
    }
View Full Code Here

    }

    private void filterFormParameters(HttpServletRequest hsr, ContainerRequest cr) throws IOException {
        if (MediaTypes.typeEquals(MediaType.APPLICATION_FORM_URLENCODED_TYPE, cr.getMediaType())
                && !isEntityPresent(cr)) {
            Form f = new Form();

            Enumeration e = hsr.getParameterNames();
            while (e.hasMoreElements()) {
                String name = (String) e.nextElement();
                String[] values = hsr.getParameterValues(name);

                f.put(name, Arrays.asList(values));
            }

            if (!f.isEmpty()) {
                cr.getProperties().put(FormDispatchProvider.FORM_PROPERTY, f);
                if (LOGGER.isLoggable(Level.WARNING)) {
                    LOGGER.log(Level.WARNING,
                            "A servlet request, to the URI " + cr.getRequestUri() + ", " +
                                    "contains form parameters in " +
View Full Code Here

    protected MultivaluedParameterExtractorProvider getMultivaluedParameterExtractorProvider() {
        return mpep;
    }

    private void processForm(HttpContext context) {
        Form form = (Form)context.getProperties().get(FORM_PROPERTY);
        if (form == null) {
            form = context.getRequest().getEntity(Form.class);
            context.getProperties().put(FORM_PROPERTY, form);
        }
    }
View Full Code Here

        }

        @Override
        public Object getValue(HttpContext context) {

            Form form = getCachedForm(context);

            if (form == null) {
                form = getForm(context);
                cacheForm(context, form);
            }
View Full Code Here

    @Produces("application/x-www-form-urlencoded")
    @GET
    public Form getFormURLEncodedRep(
            @PathParam("arg1")String arg1,
            @PathParam("arg2")String arg2) {
        Form urlProps = new Form();
        urlProps.add("representation", "FormURLEncodedRepresentation");
        urlProps.add("name", "Master Duke");
        urlProps.add("sex", "male");
        urlProps.add("arg1", arg1);
        urlProps.add("arg2", arg2);
        return urlProps;       
    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.representation.Form

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.