protected void renderComponent()

in tapestry-framework/src/org/apache/tapestry/html/Rollover.java [65:141]


    protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
    {
        // No body, so we skip it all if not rewinding (assumes no side effects on
        // accessors).

        if (cycle.isRewinding())
            return;

        String imageURL = null;
        String focusURL = null;
        String blurURL = null;
        boolean dynamic = false;
        String imageName = null;

        Body body = Body.get(cycle);
        if (body == null)
            throw new ApplicationRuntimeException(
                Tapestry.getMessage("Rollover.must-be-contained-by-body"),
                this,
                null,
                null);

        ILinkComponent serviceLink =
            (ILinkComponent) cycle.getAttribute(Tapestry.LINK_COMPONENT_ATTRIBUTE_NAME);

        if (serviceLink == null)
            throw new ApplicationRuntimeException(
                Tapestry.getMessage("Rollover.must-be-contained-by-link"),
                this,
                null,
                null);

        boolean linkDisabled = serviceLink.isDisabled();

        if (linkDisabled)
        {
            imageURL = getAssetURL(getDisabled(), cycle);

            if (imageURL == null)
                imageURL = getAssetURL(getImage(), cycle);
        }
        else
        {
            imageURL = getAssetURL(getImage(), cycle);
            focusURL = getAssetURL(getFocus(), cycle);
            blurURL = getAssetURL(getBlur(), cycle);

            dynamic = (focusURL != null) || (blurURL != null);
        }

        if (imageURL == null)
            throw Tapestry.createRequiredParameterException(this, "image");

        writer.beginEmpty("img");

        writer.attribute("src", imageURL);

        writer.attribute("border", 0);

        if (dynamic)
        {
            if (focusURL == null)
                focusURL = imageURL;

            if (blurURL == null)
                blurURL = imageURL;

            imageName = writeScript(cycle, body, serviceLink, focusURL, blurURL);

            writer.attribute("name", imageName);
        }

        renderInformalParameters(writer, cycle);

        writer.closeTag();

    }