/** * @see org.apache.tapestry.BaseComponent#renderComponent(org.apache.tapestry.IMarkupWriter, * org.apache.tapestry.IRequestCycle) */ protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) { Object objExistedTreeModelSource = cycle .getAttribute(ITreeRowSource.TREE_ROW_SOURCE_ATTRIBUTE); cycle.setAttribute(ITreeRowSource.TREE_ROW_SOURCE_ATTRIBUTE, this); super.renderComponent(writer, cycle); cycle.setAttribute(ITreeRowSource.TREE_ROW_SOURCE_ATTRIBUTE, objExistedTreeModelSource); }
public void service(IRequestCycle cycle) throws IOException { String pageName = cycle.getParameter(ServiceConstants.PAGE); String componentId = cycle.getParameter(ServiceConstants.COMPONENT); IPage componentPage = cycle.getPage(pageName); IComponent component = componentPage.getNestedComponent(componentId); if (!(component instanceof IXTile)) throw new ApplicationRuntimeException("Incorrect component type: was " + component.getClass() + " but must be " + IXTile.class, component, null, null); IXTile xtile = (IXTile) component; String[] params = cycle.getParameters(ServiceConstants.PARAMETER); cycle.setListenerParameters(params); xtile.trigger(cycle); // do not squeeze on output either Object[] args = cycle.getListenerParameters(); String strArgs = generateOutputString(args); if (strArgs != null) { OutputStream output = _response.getOutputStream(new ContentType("text/xml")); output.write(strArgs.getBytes("utf-8")); } }
/** * {@inheritDoc} */ public void renderBody(IRequestCycle cycle, Body component) { if (cycle.isRewinding()) return; renderComponent(cycle, component); // just in case _deferredFormConnections.clear(); }
/** * Invoked, typically, when an exception occurs while servicing the request. This method resets * the output, sets the new page and renders it. */ protected void redirect(String pageName, IRequestCycle cycle, ApplicationRuntimeException exception) throws IOException { IPage page = cycle.getPage(pageName); cycle.activate(page); renderResponse(cycle); }
public void service(IRequestCycle cycle) throws IOException { String pageName = cycle.getParameter(ServiceConstants.PAGE); // At one time, the page service required a session, but that is no longer necessary. // Users can now bookmark pages within a Tapestry application. Pages // can implement validate() and throw a PageRedirectException if they don't // want to be accessed this way. For example, most applications have a concept // of a "login" and have a few pages that don't require the user to be logged in, // and other pages that do. The protected pages should redirect to a login page. cycle.activate(pageName); _responseRenderer.renderResponse(cycle); }
if (cycle.getAttribute(Tapestry.LINK_COMPONENT_ATTRIBUTE_NAME) != null) throw new ApplicationRuntimeException(Tapestry.getMessage("AbstractLinkComponent.no-nesting"), linkComponent, null, null); cycle.setAttribute(Tapestry.LINK_COMPONENT_ATTRIBUTE_NAME, linkComponent); String formName = cycle.getUniqueId("LinkForm"); if (!disabled && !cycle.isRewinding()) linkComponent.renderBody(wrappedWriter, cycle); if (!disabled && !cycle.isRewinding()) cycle.removeAttribute(Tapestry.LINK_COMPONENT_ATTRIBUTE_NAME);
/** * Triggers the listener. The parameters passed are the current text * and those specified in the parameters parameter of the component. * If the listener parameter is not bound, attempt to locate an implicit * listener named by the capitalized component id, prefixed by "do". */ public void trigger(IRequestCycle cycle) { IActionListener listener = getListener(); if (listener == null) listener = getContainer().getListeners().getImplicitListener(this); Object[] params = cycle.getListenerParameters(); // replace the first param with the correct value String inputId = (String)params[0]; params[0] = cycle.getParameter(inputId); cycle.setListenerParameters(params); setSearchTriggered(true); getListenerInvoker().invokeListener(listener, this, cycle); }
/** * Invoked when rewinding a form to re-initialize the _allocatedIds and _elementIdAllocator. * Converts a string passed as a parameter (and containing a comma separated list of ids) back * into the allocateIds property. In addition, return the state of the ID allocater back to * where it was at the start of the render. * * @see #buildAllocatedIdList() * @since 3.0 */ private void reinitializeIdAllocatorForRewind() { _cycle.initializeIdState(_cycle.getParameter(SEED_IDS)); String allocatedFormIds = _cycle.getParameter(FORM_IDS); String[] ids = TapestryUtils.split(allocatedFormIds); for (int i = 0; i < ids.length; i++) _allocatedIds.add(ids[i]); // Now, reconstruct the initial state of the // id allocator. String extraReservedIds = _cycle.getParameter(RESERVED_FORM_IDS); ids = TapestryUtils.split(extraReservedIds); for (int i = 0; i < ids.length; i++) { _cycle.getUniqueId(ids[i]); } }
/** * Checks the submit name ({@link FormConstants#SUBMIT_NAME_PARAMETER}) to see if it matches * this LinkSubmit's assigned element name. */ protected boolean isClicked(IRequestCycle cycle, String name) { String value = cycle.getParameter(FormConstants.SUBMIT_NAME_PARAMETER); return name.equals(value); }
/** * Listener for the component selection, which allows a particular component. * * <p>The context is a single string, * the id path of the component to be selected (or null to inspect * the page itself). This invokes * {@link #selectComponent(String)}. * **/ public void selectComponent(IRequestCycle cycle) { Object[] parameters = cycle.getListenerParameters(); String newIdPath; // The up button may generate a null context. if (parameters == null || parameters.length == 0) newIdPath = null; else newIdPath = (String) parameters[0]; selectComponent(newIdPath); }
/** * Grabs the incoming parameters needed for json responses, most notable the * {@link ServiceConstants#UPDATE_PARTS} parameter. * * @param cycle * The request cycle to parse from */ void parseParameters(IRequestCycle cycle) { Object[] updateParts = cycle.getParameters(ServiceConstants.UPDATE_PARTS); if (updateParts == null) return; for(int i = 0; i < updateParts.length; i++) _parts.add(updateParts[i].toString()); }
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) { if (!cycle.isRewinding() && !isDisabled()) { cycle.getResponseBuilder().addExternalScript(this, getScriptAsset().getResourceLocation()); } }
/** * Simply invokes {@link #render(IMarkupWriter, IRequestCycle)}. * * @since 1.0.2 */ public void rewind(IMarkupWriter writer, IRequestCycle cycle) { cycle.getResponseBuilder().render(writer, this, cycle); }
/** * Retrieves the {@link Shell} that was stored into the request * cycle. This allows components wrapped by the {@link Shell} to * locate it and access the services it provides. * * @since 4.1.1 */ public static Shell get(IRequestCycle cycle) { return (Shell) cycle.getAttribute(SHELL_ATTRIBUTE); }
/** * Finds a component with the current address using the given RequestCycle. * * @param cycle * the RequestCycle to use to locate the component * @return IComponent a component that has been initialized for the given RequestCycle */ public IComponent findComponent(IRequestCycle cycle) { IPage objPage = cycle.getPage(_pageName); return objPage.getNestedComponent(_idPath); }
public void service(IRequestCycle cycle) throws IOException { cycle.activate(_pageName); _responseRenderer.renderResponse(cycle); }
/** * Triggers the listener. The parameters passed are the current text * and those specified in the parameters parameter of the component. * If the listener parameter is not bound, attempt to locate an implicit * listener named by the capitalized component id, prefixed by "do". */ public void trigger(IRequestCycle cycle) { IActionListener listener = getListener(); if (listener == null) listener = getContainer().getListeners().getImplicitListener(this); Object[] params = cycle.getListenerParameters(); // replace the first param with the correct value String inputId = (String)params[0]; params[0] = cycle.getParameter(inputId); cycle.setListenerParameters(params); setSearchTriggered(true); getListenerInvoker().invokeListener(listener, this, cycle); }
public void service(IRequestCycle cycle) throws IOException { String pageName = cycle.getParameter(ServiceConstants.PAGE); // At one time, the page service required a session, but that is no longer necessary. // Users can now bookmark pages within a Tapestry application. Pages // can implement validate() and throw a PageRedirectException if they don't // want to be accessed this way. For example, most applications have a concept // of a "login" and have a few pages that don't require the user to be logged in, // and other pages that do. The protected pages should redirect to a login page. cycle.activate(pageName); _responseRenderer.renderResponse(cycle); }