Package org.apache.tapestry

Examples of org.apache.tapestry.IRequestCycle


        setReturnValue(cycle, engine);
    }

    public void testLoggedOut()
    {
        IRequestCycle cycle = newCycle();
        IEngine engine = newEngine();
        IErrorProperty page = newPage();

        trainGetEngine(cycle, engine);

        trainGetVisit(engine, null);

        trainGetPage(cycle, "Home", page);

        page.setError("An error.");

        cycle.activate(page);

        replayControls();

        new ErrorPresenterImpl().presentError("An error.", cycle);
View Full Code Here


    }

    public void testLoggedIn()
    {

        IRequestCycle cycle = newCycle();
        IEngine engine = newEngine();
        IErrorProperty page = newPage();
        Visit visit = (Visit) newMock(Visit.class);

        trainGetEngine(cycle, engine);

        trainGetVisit(engine, visit);

        visit.isUserLoggedIn();
        setReturnValue(visit, true);

        trainGetPage(cycle, "MyLibrary", page);

        page.setError("An error.");

        cycle.activate(page);

        replayControls();

        new ErrorPresenterImpl().presentError("An error.", cycle);
View Full Code Here

     * specified page).
     */

    public void loginUser(Person person)
    {
        IRequestCycle cycle = getRequestCycle();

        String email = person.getEmail();

        // Get the visit object; this will likely force the
        // creation of the visit object and an HttpSession.

        Visit visit = getVisitState();
        visit.setUser(person);

        // After logging in, go to the Home page, unless otherwise
        // specified.

        ICallback callback = getCallback();

        if (callback == null)
            getMyLibrary().activate();
        else
            callback.performCallback(cycle);

        // TODO: Set max age of cookie once TAPESTRY-438 is fixed.

        getCookieSource().writeCookieValue(COOKIE_NAME, email);

        cycle.forgetPage(getPageName());
    }
View Full Code Here

     **/

    public boolean service(RequestContext context) throws ServletException, IOException
    {
        ApplicationServlet servlet = context.getServlet();
        IRequestCycle cycle = null;
        ResponseOutputStream output = null;
        IMonitor monitor = null;

        if (LOG.isDebugEnabled())
            LOG.debug("Begin service " + context.getRequestURI());

        if (_specification == null)
            _specification = servlet.getApplicationSpecification();

        // The servlet invokes setLocale() before invoking service().  We want
        // to ignore that setLocale() ... that is, not force a cookie to be
        // written.

        _localeChanged = false;

        if (_resolver == null)
            _resolver = servlet.getResourceResolver();

        try
        {
            setupForRequest(context);

            monitor = getMonitor(context);

            output = new ResponseOutputStream(context.getResponse());
        }
        catch (Exception ex)
        {
            reportException(Tapestry.getMessage("AbstractEngine.unable-to-begin-request"), ex);

            throw new ServletException(ex.getMessage(), ex);
        }

        IEngineService service = null;

        try
        {
            try
            {
                String serviceName;

                try
                {
                    serviceName = extractServiceName(context);

                    if (Tapestry.isBlank(serviceName))
                        serviceName = Tapestry.HOME_SERVICE;

                    // Must have a service to create the request cycle.
                    // Must have a request cycle to report an exception.

                    service = getService(serviceName);
                }
                catch (Exception ex)
                {
                    service = getService(Tapestry.HOME_SERVICE);
                    cycle = createRequestCycle(context, service, monitor);

                    throw ex;
                }

                cycle = createRequestCycle(context, service, monitor);

                monitor.serviceBegin(serviceName, context.getRequestURI());

                // Invoke the service, which returns true if it may have changed
                // the state of the engine (most do return true).

                service.service(this, cycle, output);

                // Return true only if the engine is actually dirty.  This cuts down
                // on the number of times the engine is stored into the
                // session unceccesarily.

                return _dirty;
            }
            catch (PageRedirectException ex)
            {
                handlePageRedirectException(ex, cycle, output);
            }
            catch (RedirectException ex)
            {
                handleRedirectException(cycle, ex);
            }
            catch (StaleLinkException ex)
            {
                handleStaleLinkException(ex, cycle, output);
            }
            catch (StaleSessionException ex)
            {
                handleStaleSessionException(ex, cycle, output);
            }
        }
        catch (Exception ex)
        {
            monitor.serviceException(ex);

            // Discard any output (if possible).  If output has already been sent to
            // the client, then things get dicey.  Note that this block
            // gets activated if the StaleLink or StaleSession pages throws
            // any kind of exception.

            // Attempt to switch to the exception page.  However, this may itself fail
            // for a number of reasons, in which case a ServletException is thrown.

            output.reset();

            if (LOG.isDebugEnabled())
                LOG.debug("Uncaught exception", ex);

            activateExceptionPage(cycle, output, ex);
        }
        finally
        {
            if (service != null)
                monitor.serviceEnd(service.getName());

            try
            {
                cycle.cleanup();

                // Closing the buffered output closes the underlying stream as well.

                if (output != null)
                    output.forceFlush();
View Full Code Here

*/
public class AbstractTableViewComponent extends BaseComponent
{
    public ITableModelSource getTableModelSource()
    {
        IRequestCycle objCycle = getPage().getRequestCycle();

        ITableModelSource objSource =
            (ITableModelSource) objCycle.getAttribute(
                ITableModelSource.TABLE_MODEL_SOURCE_ATTRIBUTE);

        if (objSource == null)
            throw new ApplicationRuntimeException(
                "The component "
View Full Code Here

  public IAsset getSortImage()
  {
    IAsset objImageAsset;

    IRequestCycle objCycle = getPage().getRequestCycle();
    ITableSortingState objSortingState = getTableModel().getSortingState();
    if (objSortingState.getSortOrder()
      == ITableSortingState.SORT_ASCENDING)
    {
      objImageAsset =
        (IAsset) objCycle.getAttribute(
          TableColumns.TABLE_COLUMN_ARROW_UP_ATTRIBUTE);
      if (objImageAsset == null)
        objImageAsset = getAsset("sortUp");
    }
    else
    {
      objImageAsset =
        (IAsset) objCycle.getAttribute(
          TableColumns.TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE);
      if (objImageAsset == null)
        objImageAsset = getAsset("sortDown");
    }
View Full Code Here

  public IAsset getSortImage()
  {
    IAsset objImageAsset;

    IRequestCycle objCycle = getPage().getRequestCycle();
    ITableSortingState objSortingState = getTableModel().getSortingState();
    if (objSortingState.getSortOrder()
      == ITableSortingState.SORT_ASCENDING)
    {
      objImageAsset =
        (IAsset) objCycle.getAttribute(
          TableColumns.TABLE_COLUMN_ARROW_UP_ATTRIBUTE);
      if (objImageAsset == null)
        objImageAsset = getAsset("sortUp");
    }
    else
    {
      objImageAsset =
        (IAsset) objCycle.getAttribute(
          TableColumns.TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE);
      if (objImageAsset == null)
        objImageAsset = getAsset("sortDown");
    }
View Full Code Here

*/
public class AbstractTableRowComponent extends AbstractTableViewComponent
{
    public ITableRowSource getTableRowSource()
    {
        IRequestCycle objCycle = getPage().getRequestCycle();

        Object objSourceObj = objCycle.getAttribute(ITableRowSource.TABLE_ROW_SOURCE_ATTRIBUTE);
        ITableRowSource objSource = (ITableRowSource) objSourceObj;

        if (objSource == null)
            throw new ApplicationRuntimeException(
                "The component "
View Full Code Here

    {
        Object objValue = objConvertedTableRow;

        IPrimaryKeyConvertor objConvertor = getCachedConvertor();
        if (objConvertor != null) {
            IRequestCycle objCycle = getPage().getRequestCycle();
            if (objCycle.isRewinding()) {
                objValue = objConvertor.getValue(objConvertedTableRow)
            }
            else {
                Map mapConvertedValues = getConvertedValues();
                objValue = mapConvertedValues.get(objConvertedTableRow);
View Full Code Here

        super(location);
    }

    public void write(StringBuffer buffer, ScriptSession session)
    {
        IRequestCycle cycle = session.getRequestCycle();

        ILocation location = getLocation();
        String tag = "<unique> " + location.toString();

        if (cycle.getAttribute(tag) != null)
            return;

        cycle.setAttribute(tag, Boolean.TRUE);

        writeChildren(buffer, session);
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.IRequestCycle

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.