Search in sources :

Example 1 with TagCannotBeEnclosedRuntimeException

use of org.jaffa.presentation.portlet.widgets.taglib.exceptions.TagCannotBeEnclosedRuntimeException 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

UserSession (org.jaffa.presentation.portlet.session.UserSession)1 UserGridManager (org.jaffa.presentation.portlet.widgets.controller.UserGridManager)1 JspWriteRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException)1 OuterFormTagMissingRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.OuterFormTagMissingRuntimeException)1 TagCannotBeEnclosedRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.TagCannotBeEnclosedRuntimeException)1