Package javax.servlet.jsp

Examples of javax.servlet.jsp.JspContext


     * @param string to be written to the response.
     */
    protected final void write(String string)
            throws JspException
    {
        JspContext ctxt = getJspContext();
        JspWriter writer = ctxt.getOut();
        try {
            writer.print(string);
        }
        catch (IOException e) {
            logger.error(Bundle.getString("Tags_WriteException"), e);
View Full Code Here


     * it will log an exception.
     * @return PageContext
     */
    protected PageContext getPageContext()
    {
        JspContext ctxt = getJspContext();
        if (ctxt instanceof PageContext)
            return (PageContext) ctxt;

        // assert the page context and log an error in production
        assert(false) : "The JspContext was not a PageContext";
View Full Code Here

     * @param string to be written to the response.
     */
    protected final void write(String string)
            throws JspException
    {
        JspContext ctxt = getJspContext();
        JspWriter writer = ctxt.getOut();
        try {
            writer.print(string);
        }
        catch (IOException e) {
            logger.error(Bundle.getString("Tags_WriteException"), e);
View Full Code Here

        this.bodyLoopCount = bodyLoopCount;
    }
   
    public void doTag() throws JspException, IOException
    {
        JspContext ctx = getJspContext();
        JspWriter w = ctx.getOut();
        w.println("enter TestSimpleTag " + name);
        JspFragment f = getJspBody();
        for(int i = 0; i < bodyLoopCount; ++i)
        {
            w.println("invoking body i=" + i);
View Full Code Here

        return null;
    }

    @Override
    public Object getValue(ELContext context, Object base, Object property) {
        JspContext pageContext = (JspContext) context.getContext(JspContext.class);
        Boolean escapeXml = (Boolean) pageContext.getAttribute(ESCAPE_XML_ATTRIBUTE);
        if (escapeXml != null && !escapeXml) {
            return null;
        }

        try {
View Full Code Here

        assertEquals("&lt;h1&gt;&amp;&#039;&#034;", value);
    }

    @Test
    public void getValue_should_not_escape_value_when_disabled() {
        JspContext pageContext = (JspContext) elContext.getContext(JspContext.class);
        pageContext.setAttribute(EscapeXmlELResolver.ESCAPE_XML_ATTRIBUTE, Boolean.FALSE);
       
        String value = (String) compositeResolver.getValue(elContext, BASE, PROPERTY);
        assertEquals(VALUE, value);
    }
View Full Code Here

    public void doTag() throws JspException, IOException {
        String formatted =
            new SimpleDateFormat("long".equals(format)?"EEE 'the' d:MMM:yyyy":"d:MM:yy")
            .format(new Date());
        StringTokenizer tok = new StringTokenizer(formatted,":");
        JspContext context = getJspContext();
        context.setAttribute("day", tok.nextToken() );
        context.setAttribute("month", tok.nextToken() );
        context.setAttribute("year", tok.nextToken() );

        JspFragment fragment = getJspBody();
        fragment.invoke(null);
    }
View Full Code Here

    /**
     * Using a {@link DataGridConfig} object, access the {@link DataGridState} and place
     * it in the {@link JspContext} under the attribute key set via {@link #setVar(String)}
     */
    public void doTag() {
        JspContext jspContext = getJspContext();
        DataGridStateFactory factory = DataGridStateFactory.getInstance(jspContext);
        assert factory != null;

        DataGridState state = null;
        if(_config != null)
            state = factory.getDataGridState(_name, _config);
        else
            state = factory.getDataGridState(_name);

        jspContext.setAttribute(_var, state);
    }
View Full Code Here

     * @throws JspException when the {@link DataGridTagModel} can not be found in the {@link JspContext}
     */
    public void doTag()
            throws IOException, JspException {

        JspContext jspContext = getJspContext();

        DataGridTagModel dgm = DataGridUtil.getDataGridTagModel(jspContext);
        if(dgm == null)
            throw new JspException(Bundle.getErrorString("DataGridTags_MissingDataGridModel"));

View Full Code Here

     * @throws JspException when the {@link DataGridTagModel} can not be found in the {@link JspContext}
     */
    public void doTag()
            throws JspException, IOException {

        JspContext jspContext = getJspContext();
        DataGridTagModel dgm = DataGridUtil.getDataGridTagModel(jspContext);
        if(dgm == null)
            throw new JspException(Bundle.getErrorString("DataGridTags_MissingDataGridModel"));

        int gridRenderState = dgm.getRenderState();
        if(gridRenderState == DataGridTagModel.RENDER_STATE_HEADER) {

            InternalStringBuilder content = new InternalStringBuilder();
            AbstractRenderAppender appender = new StringBuilderRenderAppender(content);

            StyleModel styleModel = dgm.getStyleModel();
            assert styleModel != null;

            TableRenderer tableRenderer = dgm.getTableRenderer();
            assert tableRenderer != null;

            if(dgm.isRenderRowGroups()) {
                _theadTag.styleClass = (_theadTag.styleClass != null ? _theadTag.styleClass : styleModel.getTableHeadClass());
                tableRenderer.openTableHead(_theadTag, appender);
            }

            TrTag.State trState = null;
            if(_renderRow) {
                trState = new TrTag.State();
                trState.styleClass = styleModel.getHeaderRowClass();
                tableRenderer.openHeaderRow(trState, appender);
            }

            JspFragment fragment = getJspBody();
            if(fragment != null) {
                StringWriter sw = new StringWriter();
                fragment.invoke(sw);
                appender.append(sw.toString());
            }

            if(_renderRow)
                tableRenderer.closeHeaderRow(appender);

            if(dgm.isRenderRowGroups()) {
                tableRenderer.closeTableHead(appender);
                String tfootScript = null;
                if(_theadTag.id != null) {
                    HttpServletRequest request = JspUtil.getRequest(getJspContext());
                    tfootScript = renderNameAndId(request, _theadTag, null);
                }

                if(tfootScript != null)
                    appender.append(tfootScript);
            }

            jspContext.getOut().write(content.toString());
        }
    }
View Full Code Here

TOP

Related Classes of javax.servlet.jsp.JspContext

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.