Search in sources :

Example 11 with JspWriteRuntimeException

use of org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException in project jaffa-framework by jaffa-projects.

the class ButtonTag method otherDoStartTagOperations.

// 
// methods called from doStartTag()
// 
/**
 * This generates the HTML for the tag.
 */
public void otherDoStartTagOperations() {
    try {
        super.otherDoStartTagOperations();
    } catch (JspException e) {
        log.error("ButtonTag.otherDoStartTagOperations() error: " + e);
    }
    // 
    // TODO: code that performs other operations in doStartTag
    // should be placed here.
    // It will be called after initializing variables,
    // finding the parent, setting IDREFs, etc, and
    // before calling theBodyShouldBeEvaluated().
    // 
    // check if the tag is enclosed
    boolean enclosed = TagHelper.isEnclosed(pageContext);
    // Get the formtag from the page & register the widget
    FormTag formTag = TagHelper.getFormTag(pageContext);
    if (formTag == null) {
        String str = "The " + TAG_NAME + " should be inside a FormTag";
        log.error(str);
        throw new OuterFormTagMissingRuntimeException(str);
    }
    if (getGuarded())
        formTag.registerGuardedButton();
    // Generate the HTML
    JspWriter out = pageContext.getOut();
    String formName = TagHelper.getFormTag(pageContext).getHtmlName();
    String idPrefix = getHtmlIdPrefix();
    String eventPrefix = getJaffaEventNamePrefix();
    try {
        out.println(getHtml(idPrefix, eventPrefix, formName, enclosed));
    } catch (IOException e) {
        String str = "Exception in writing the " + TAG_NAME;
        log.error(str, e);
        throw new JspWriteRuntimeException(str, e);
    }
}
Also used : JspWriteRuntimeException(org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException) JspException(javax.servlet.jsp.JspException) OuterFormTagMissingRuntimeException(org.jaffa.presentation.portlet.widgets.taglib.exceptions.OuterFormTagMissingRuntimeException) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 12 with JspWriteRuntimeException

use of org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException in project jaffa-framework by jaffa-projects.

the class DropDownTag method otherDoStartTagOperations.

/**
 * This gets the WidgetModel for the field from the pageContext.
 */
public void otherDoStartTagOperations() {
    try {
        super.otherDoStartTagOperations();
    } catch (JspException e) {
        log.error("DropDownTag.otherDoStartTagOperations() error=" + e);
    }
    // Preprocess if within a Property widget
    m_propertyRuleIntrospector = lookupPropertyTag();
    // raise an error, if the 'field' is null
    if (getField() == null) {
        String str = "The " + TAG_NAME + " requires 'field' parameter to be supplied or it should be within a PropertyTag";
        log.error(str);
        throw new MissingParametersRuntimeException(str);
    }
    // Determine the m_model. The HTML will be rendered in the otherDoEndTagOperations() method
    try {
        m_model = (SimpleWidgetModel) TagHelper.getModel(pageContext, getField(), TAG_NAME);
    } catch (ClassCastException e) {
        String str = "Wrong WidgetModel for " + TAG_NAME + " on field " + getField();
        log.error(str, e);
        throw new JspWriteRuntimeException(str, e);
    }
    try {
        // Check for an IPropertyRuleIntrospector, if this tag is not within a Property widget
        if (m_propertyRuleIntrospector == null)
            m_propertyRuleIntrospector = TagHelper.getPropertyRuleIntrospector(pageContext, getField());
        // Wrap the propertyRuleIntrospector
        m_propertyRuleIntrospector = TagHelper.wrapPropertyRuleIntrospector(m_propertyRuleIntrospector, m_model);
        if (log.isDebugEnabled())
            log.debug(this.NAME + " [field=" + getField() + "] PropertyRuleIntrospector is " + m_propertyRuleIntrospector);
    } catch (JspException e) {
        log.error("DropDownTag.otherDoStartTagOperations(): error wrapping property rule inspector=" + e);
    }
    if (m_propertyRuleIntrospector.isHidden()) {
        // Display the (Restricted) text for a hidden field
        try {
            pageContext.getOut().print(TagHelper.getTextForHiddenField(pageContext));
        } catch (IOException e) {
            String str = "Exception in writing the " + TAG_NAME;
            log.error(str, e);
            throw new JspWriteRuntimeException(str, e);
        }
    } else {
        if (m_propertyRuleIntrospector.isReadOnly())
            m_displayOnly = true;
    }
}
Also used : JspWriteRuntimeException(org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException) MissingParametersRuntimeException(org.jaffa.presentation.portlet.widgets.taglib.exceptions.MissingParametersRuntimeException)

Example 13 with JspWriteRuntimeException

use of org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException in project jaffa-framework by jaffa-projects.

the class FooterTag method otherDoStartTagOperations.

/**
 * Called from the doStartTag()
 */
public void otherDoStartTagOperations() throws JspException {
    super.otherDoStartTagOperations();
    JspWriter writer = pageContext.getOut();
    StringBuffer buf = new StringBuffer();
    Boolean bool = null;
    buf.append("<SCRIPT type=\"text/javascript\" src=\"jaffa/js/panels/footer.js\"></SCRIPT>\n");
    // Generate the html for the error-popup if required
    bool = (Boolean) pageContext.findAttribute(TagHelper.ATTRIBUTE_ERROR_BOX_IN_SAME_WINDOW);
    if (bool != null && bool.booleanValue())
        buf.append(getErrorBoxHtml());
    // Generate the html for the keyboard if required
    bool = (Boolean) pageContext.findAttribute(TagHelper.ATTRIBUTE_KEYBOARD_IN_USE);
    if (bool != null && bool.booleanValue())
        buf.append(getKeyboardHtml());
    // Generate the html for the keypad if required
    bool = (Boolean) pageContext.findAttribute(TagHelper.ATTRIBUTE_KEYPAD_IN_USE);
    if (bool != null && bool.booleanValue())
        buf.append(getKeyboardHtml());
    try {
        writer.println(buf.toString());
    } catch (IOException e) {
        String str = "Exception in writing the FooterTag";
        log.error(str, e);
        throw new JspWriteRuntimeException(str, e);
    }
}
Also used : JspWriteRuntimeException(org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 14 with JspWriteRuntimeException

use of org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException in project jaffa-framework by jaffa-projects.

the class GridTag method otherDoEndTagOperations.

/**
 * Concludes the html for the grid tag.
 * Called from the doEndTag()
 */
public void otherDoEndTagOperations() throws JspException {
    super.otherDoEndTagOperations();
    try {
        JspWriter out = pageContext.getOut();
        out.println(getEndingHtml());
        if (OUTPUT_TYPE_WEB_PAGE.equals(m_outputType) && isUserGrid())
            out.println(writeSettingsTable());
    } catch (IOException e) {
        String str = "Exception in writing the " + TAG_NAME;
        log.error(str, e);
        throw new JspWriteRuntimeException(str, e);
    }
}
Also used : JspWriteRuntimeException(org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 15 with JspWriteRuntimeException

use of org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException in project jaffa-framework by jaffa-projects.

the class GridTag method otherDoStartTagOperations.

/**
 * Sets the GridModel and an iterator on the rows of the GridModel.
 */
public void otherDoStartTagOperations() throws JspException {
    super.otherDoStartTagOperations();
    // Ensure a correct value is passed in outputType
    if (m_outputType == null)
        m_outputType = OUTPUT_TYPE_WEB_PAGE;
    else if (!OUTPUT_TYPE_WEB_PAGE.equals(m_outputType) && !OUTPUT_TYPE_EXCEL.equals(m_outputType) && !OUTPUT_TYPE_XML.equals(m_outputType))
        throw new IllegalArgumentException("Illegal outputType '" + m_outputType + "' passed to the " + TAG_NAME + ". Valid values are " + OUTPUT_TYPE_WEB_PAGE + ',' + OUTPUT_TYPE_EXCEL + ',' + OUTPUT_TYPE_XML);
    // The grid tag cannot be enclosed withing another tag !!!
    if (TagHelper.isEnclosed(pageContext)) {
        String str = "The " + TAG_NAME + " cannot be enclosed within another tag";
        log.error(str);
        throw new TagCannotBeEnclosedRuntimeException(str);
    }
    // Store the Original Attributes
    m_originalAttributes = TagHelper.getOriginalAttributes(pageContext);
    // Get the formtag from the page & register the widget
    FormTag formTag = TagHelper.getFormTag(pageContext);
    if (formTag == null) {
        String str = "The " + TAG_NAME + " should be inside a FormTag";
        log.error(str);
        throw new OuterFormTagMissingRuntimeException(str);
    }
    // Get the model
    try {
        m_model = (GridModel) TagHelper.getModel(pageContext, getField(), TAG_NAME);
    } catch (ClassCastException e) {
        String str = "Wrong WidgetModel for " + TAG_NAME + " on field " + getField();
        log.error(str, e);
        throw new JspWriteRuntimeException(str, e);
    }
    if (m_model != null) {
        Collection rows = m_model.getRows();
        if (rows != null && rows.size() > 0) {
            m_hasRows = true;
            m_modelIterator = rows.iterator();
        }
    }
    if (isUserGrid()) {
        // raise an error, if the error-flag is set on the model
        if (m_model.getErrorInSavingUserSettings()) {
            TagHelper.getFormBase(pageContext).raiseError((HttpServletRequest) pageContext.getRequest(), ActionMessages.GLOBAL_MESSAGE, "error.widgets.usergrid.savefailed");
            m_model.setErrorInSavingUserSettings(false);
        }
        // See if there are any user configuration settings available for this user and grid.
        UserSession us = UserSession.getUserSession((HttpServletRequest) pageContext.getRequest());
        UserGridManager userGridManager = new UserGridManager();
        // returns null if no configuration settings are found.
        m_selectedCols = userGridManager.getColSettings(us.getUserId(), getUserGridId());
    // @todo: There was legacy code at this point as we used to store translated labels
    // in the XML files. We have for a while now, only stored labels. This TODO is to add
    // back in the legacy support...if the need arises.
    }
    // Determine based on widget type and Context rules if user has disabled hints
    if (!m_popupHintsSet) {
        m_popupHints = isUserGrid();
        String rule = isUserGrid() ? RULE_USERGRID_POPUP : RULE_GRID_POPUP;
        String popupHints = (String) ContextManagerFactory.instance().getProperty(rule);
        if (popupHints != null)
            m_popupHints = Boolean.valueOf(popupHints).booleanValue();
        log.debug("popupHints (from rule: " + rule + ") defaults to " + m_popupHints);
    }
}
Also used : JspWriteRuntimeException(org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException) UserSession(org.jaffa.presentation.portlet.session.UserSession) OuterFormTagMissingRuntimeException(org.jaffa.presentation.portlet.widgets.taglib.exceptions.OuterFormTagMissingRuntimeException) TagCannotBeEnclosedRuntimeException(org.jaffa.presentation.portlet.widgets.taglib.exceptions.TagCannotBeEnclosedRuntimeException) UserGridManager(org.jaffa.presentation.portlet.widgets.controller.UserGridManager)

Aggregations

JspWriteRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException)18 IOException (java.io.IOException)15 JspWriter (javax.servlet.jsp.JspWriter)14 JspException (javax.servlet.jsp.JspException)8 OuterFormTagMissingRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.OuterFormTagMissingRuntimeException)8 MissingParametersRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.MissingParametersRuntimeException)7 SimpleWidgetModel (org.jaffa.presentation.portlet.widgets.model.SimpleWidgetModel)5 IPropertyRuleIntrospector (org.jaffa.rules.IPropertyRuleIntrospector)5 FormBase (org.jaffa.presentation.portlet.FormBase)2 Iterator (java.util.Iterator)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 ActionMessage (org.apache.struts.action.ActionMessage)1 ActionMessages (org.apache.struts.action.ActionMessages)1 UserSession (org.jaffa.presentation.portlet.session.UserSession)1 UserGridManager (org.jaffa.presentation.portlet.widgets.controller.UserGridManager)1 ImageModel (org.jaffa.presentation.portlet.widgets.model.ImageModel)1 TableModel (org.jaffa.presentation.portlet.widgets.model.TableModel)1 TagCannotBeEnclosedRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.TagCannotBeEnclosedRuntimeException)1