Package org.displaytag.util

Examples of org.displaytag.util.ParamEncoder


    }

    public byte[] runPage(String jspPage) throws Exception
    {

        ParamEncoder encoder = new ParamEncoder("table");
        String mediaParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_EXPORTTYPE);
        WebRequest request = new GetMethodWebRequest(getJspUrl(jspPage));

        // this will force media type initialization
        ExportViewFactory.getInstance();
        MediaTypeEnum excelMedia = MediaTypeEnum.EXCEL;
View Full Code Here


    @Test
    public void doTest() throws Exception
    {

        WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
        ParamEncoder p1 = new ParamEncoder("table");
        ParamEncoder p2 = new ParamEncoder("table2");

        request.setParameter(p2.encodeParameterName(TableTagParameters.PARAMETER_SORT), "number");
        request.setParameter(p2.encodeParameterName(TableTagParameters.PARAMETER_SORTUSINGNAME), "1");

        WebResponse response = runner.getResponse(request);

        if (log.isDebugEnabled())
        {
            log.debug("RESPONSE: " + response.getText());
        }

        WebLink[] links = response.getLinks();

        Assert.assertEquals(
            "0",
            links[0].getParameterValues(p1.encodeParameterName(TableTagParameters.PARAMETER_SORT))[0]);
        Assert.assertEquals(
            "2",
            links[0].getParameterValues(p1.encodeParameterName(TableTagParameters.PARAMETER_ORDER))[0]);

        Assert.assertEquals(
            "buzz",
            links[1].getParameterValues(p1.encodeParameterName(TableTagParameters.PARAMETER_SORT))[0]);
        Assert.assertEquals(
            "2",
            links[1].getParameterValues(p1.encodeParameterName(TableTagParameters.PARAMETER_ORDER))[0]);

        // test that the column with sortName buzz was set as sorted and now has a link to sort desc
        Assert.assertEquals(
            "number",
            links[2].getParameterValues(p2.encodeParameterName(TableTagParameters.PARAMETER_SORT))[0]);
        Assert.assertEquals(
            "1",
            links[2].getParameterValues(p2.encodeParameterName(TableTagParameters.PARAMETER_ORDER))[0]);

        // now ensure that our data has not been sorted at all since we are doing it 'externally'
        WebTable[] tables = response.getTables();
        Assert.assertEquals("1", tables[1].getCellAsText(1, 0));
        Assert.assertEquals("4", tables[1].getCellAsText(2, 0));
View Full Code Here

    private void writeFormFields(TableModel model)
    {
        Map<String, String[]> parameters = baseHref.getParameterMap();

        ParamEncoder pe = new ParamEncoder(model.getId());

        addIfMissing(parameters, pe.encodeParameterName(TableTagParameters.PARAMETER_ORDER));
        addIfMissing(parameters, pe.encodeParameterName(TableTagParameters.PARAMETER_PAGE));
        addIfMissing(parameters, pe.encodeParameterName(TableTagParameters.PARAMETER_SORT));

        for (Iterator<String> it = parameters.keySet().iterator(); it.hasNext();)
        {
            String key = it.next();
            Object value = parameters.get(key);
View Full Code Here

    {
        // paramEncoder has been already instantiated?
        if (this.paramEncoder == null)
        {
            // use the id attribute to get the unique identifier
            this.paramEncoder = new ParamEncoder(model.getId());
        }

        return this.paramEncoder.encodeParameterName(parameterName);
    }
View Full Code Here

    @Test
    public void doTest() throws Exception
    {

        WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
        ParamEncoder pe = new ParamEncoder("table");

        request.setParameter(pe.encodeParameterName(TableTagParameters.PARAMETER_PAGE), "2");

        WebResponse response = runner.getResponse(request);

        if (log.isDebugEnabled())
        {
View Full Code Here

    {
        // test keep
        WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));

        // test remove
        ParamEncoder encoder = new ParamEncoder("table");
        String mediaParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_EXPORTTYPE);

        request.setParameter(mediaParameter, Integer.toString(MediaTypeEnum.XML.getCode()));

        WebResponse response = runner.getResponse(request);
View Full Code Here

    @Override
    @Test
    public void doTest() throws Exception
    {
        WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
        ParamEncoder encoder = new ParamEncoder("table");
        request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_PAGE), "3");

        WebResponse response = runner.getResponse(request);

        if (log.isDebugEnabled())
        {
View Full Code Here

    @Override
    @Test
    public void doTest() throws Exception
    {

        ParamEncoder encoder = new ParamEncoder("table");
        String mediaParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_EXPORTTYPE);

        WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
        request.setParameter(mediaParameter, Integer.toString(MediaTypeEnum.CSV.getCode()));

        WebResponse response = runner.getResponse(request);
View Full Code Here

        Assert.assertEquals("Wrong number of links in result.", 4, links.length);

        URLAssert.assertEquals(
            CONTEXT
                + "/goforit?"
                + new ParamEncoder("table").encodeParameterName(TableTagParameters.PARAMETER_EXPORTTYPE)
                + "=1&"
                + TableTagParameters.PARAMETER_EXPORTING
                + "=1",
            links[0].getURLString());
    }
View Full Code Here

            if (splittedExcludedParams.length == 1 && "*".equals(splittedExcludedParams[0]))
            {
                // @todo cleanup: paramEncoder initialization should not be done here
                if (this.paramEncoder == null)
                {
                    this.paramEncoder = new ParamEncoder(getUid());
                }

                Iterator<String> paramsIterator = baseHref.getParameterMap().keySet().iterator();
                while (paramsIterator.hasNext())
                {
View Full Code Here

TOP

Related Classes of org.displaytag.util.ParamEncoder

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.