diff --git a/voila-runtime-springmvc/src/main/java/it/mice/voila/runtime/springmvc/taglibs/InternalFrameTag.java b/voila-runtime-springmvc/src/main/java/it/mice/voila/runtime/springmvc/taglibs/InternalFrameTag.java index 5521b9b4771862031b7180e414edfa87bc0d3413..5bce1c48d4fb2f165ad9a14517b2c624eb05766f 100644 --- a/voila-runtime-springmvc/src/main/java/it/mice/voila/runtime/springmvc/taglibs/InternalFrameTag.java +++ b/voila-runtime-springmvc/src/main/java/it/mice/voila/runtime/springmvc/taglibs/InternalFrameTag.java @@ -9,49 +9,51 @@ import javax.servlet.jsp.JspException; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.springframework.context.MessageSource; -import org.springframework.context.NoSuchMessageException; import org.springframework.web.servlet.tags.form.AbstractHtmlElementTag; import org.springframework.web.servlet.tags.form.TagWriter; public class InternalFrameTag extends AbstractHtmlElementTag { - /** + /** */ private static final long serialVersionUID = 1L; private static final String STYLE_PRIMARY = "primary"; private static final String STYLE_DEFAULT = "default"; private static final String STYLE_TAB_CONTENT = "tab-content"; - + private String frameId = null; private String style = STYLE_PRIMARY; - private String legendLabel = null; - private boolean collapsable = false; - private boolean closeable = false; - private boolean goTopLink = false; - private String initialState = "expanded"; - private String modes = null; - private boolean useFieldset = true; - - private String cmdLabel1; - private String cmdAction1; - private String cmdTitle1; - private String cmdLabel2; - private String cmdAction2; - private String cmdTitle2; - private String cmdLabel3; - private String cmdAction3; - private String cmdTitle3; - private String cmdLabel4; - private String cmdAction4; - private String cmdTitle4; + private String legendLabel = null; + private boolean collapsable = false; + private boolean closeable = false; + private boolean goTopLink = false; + private String initialState = "expanded"; + private String modes = null; + private boolean useFieldset = true; + + private String cmdLabel1; + private String cmdAction1; + private String cmdTitle1; + private String cmdLabel2; + private String cmdAction2; + private String cmdTitle2; + private String cmdLabel3; + private String cmdAction3; + private String cmdTitle3; + private String cmdLabel4; + private String cmdAction4; + private String cmdTitle4; + + private String toolBoxAlign; + private boolean customCollapseIcon; private TagWriter tagWriter; private Collection commandList = new ArrayList(); - + public boolean isStyleTabContent() { return STYLE_TAB_CONTENT.equals(getStyle()); } - + public String getModes() { return modes; } @@ -232,39 +234,39 @@ public class InternalFrameTag extends AbstractHtmlElementTag { protected int writeTagContent(TagWriter tagWriter) throws JspException { this.tagWriter = tagWriter; - MessageSource messageSource = getRequestContext().getMessageSource(); - - processFrameCommands(messageSource); + MessageSource messageSource = getRequestContext().getMessageSource(); + + processFrameCommands(messageSource); + + writeFieldsetAndLegend(messageSource); + + if (TagUtils.isBootstrapTheme()) { + tagWriter.startTag("div"); + tagWriter.writeAttribute("id", "IFB" + getFrameId()); + tagWriter.writeAttribute(CLASS_ATTRIBUTE, "box-body"); + if (isCollapsable() && getInitialState() != null && getInitialState().equalsIgnoreCase("collapsed")) { + tagWriter.writeAttribute(STYLE_ATTRIBUTE, "display: none;"); + } + tagWriter.forceBlock(); + if (isStyleTabContent()) { + String label = TagUtils.getMessage(getRequestContext(), evaluate("legendLabel", legendLabel)); + label = getDisplayString(label); + writeBoxTitle(label); + } + } else { + tagWriter.startTag("div"); + tagWriter.writeAttribute("id", "IFB" + getFrameId()); + if (isCollapsable() && getInitialState() != null && getInitialState().equalsIgnoreCase("collapsed")) { + tagWriter.writeAttribute(CLASS_ATTRIBUTE, "layerFrameBodyCollapsed"); + } else { + tagWriter.writeAttribute(CLASS_ATTRIBUTE, "layerFrameBody"); + } + tagWriter.forceBlock(); + } + + return EVAL_BODY_INCLUDE; + } - writeFieldsetAndLegend(messageSource); - - if (TagUtils.isBootstrapTheme()) { - tagWriter.startTag("div"); - tagWriter.writeAttribute("id", "IFB" + getFrameId()); - tagWriter.writeAttribute(CLASS_ATTRIBUTE, "box-body"); - if (isCollapsable() && getInitialState() != null && getInitialState().equalsIgnoreCase("collapsed")) { - tagWriter.writeAttribute(STYLE_ATTRIBUTE, "display: none;"); - } - tagWriter.forceBlock(); - if (isStyleTabContent()) { - String label = TagUtils.getMessage(getRequestContext(), evaluate("legendLabel", legendLabel)); - label = getDisplayString(label); - writeBoxTitle(label); - } - } else { - tagWriter.startTag("div"); - tagWriter.writeAttribute("id", "IFB" + getFrameId()); - if (isCollapsable() && getInitialState() != null && getInitialState().equalsIgnoreCase("collapsed")) { - tagWriter.writeAttribute(CLASS_ATTRIBUTE, "layerFrameBodyCollapsed"); - } else { - tagWriter.writeAttribute(CLASS_ATTRIBUTE, "layerFrameBody"); - } - tagWriter.forceBlock(); - } - - return EVAL_BODY_INCLUDE; - } - private void processFrameCommands(MessageSource messageSource) throws JspException { processFrameCommand(messageSource, getCmdLabel1(), getCmdAction1(), getCmdTitle1()); processFrameCommand(messageSource, getCmdLabel2(), getCmdAction2(), getCmdTitle2()); @@ -272,8 +274,8 @@ public class InternalFrameTag extends AbstractHtmlElementTag { processFrameCommand(messageSource, getCmdLabel4(), getCmdAction4(), getCmdTitle4()); } - private void processFrameCommand(MessageSource messageSource, - String label, String action, String title) throws JspException { + private void processFrameCommand(MessageSource messageSource, String label, String action, String title) + throws JspException { if (StringUtils.isEmpty(action)) { return; @@ -283,7 +285,7 @@ public class InternalFrameTag extends AbstractHtmlElementTag { commandBean.setLabel(TagUtils.getMessage(getRequestContext(), evaluate("label", label))); commandBean.setTitle(TagUtils.getMessage(getRequestContext(), evaluate("title", title))); - getCommandList().add(commandBean); + getCommandList().add(commandBean); } private void writeFieldsetAndLegend(MessageSource messageSource) throws JspException { @@ -300,25 +302,26 @@ public class InternalFrameTag extends AbstractHtmlElementTag { } else { tagWriter.startTag("div"); } - + if (StringUtils.isEmpty(getCssClass())) { - setCssClass("box box-solid box-primary"); + setCssClass("box box-solid box-primary"); } - if (isCollapsable() && getInitialState() != null && getInitialState().equalsIgnoreCase("collapsed")) { + if (isCollapsable() && getInitialState() != null && getInitialState().equalsIgnoreCase("collapsed")) { setCssClass(getCssClass() + " collapsed-box"); - } + } tagWriter.writeAttribute("id", "IF" + getFrameId()); try { writeOptionalAttributes(tagWriter); } catch (Exception e) { - logger.debug(e + " raised during internal frame rendering. Probably the frame was used out of a BindingResult object resolution. Ignoring..."); + logger.debug(e + + " raised during internal frame rendering. Probably the frame was used out of a BindingResult object resolution. Ignoring..."); } if (isStyleTabContent()) { return; } - + String label = TagUtils.getMessage(getRequestContext(), evaluate("legendLabel", legendLabel)); label = getDisplayString(label); if (StringUtils.isEmpty(label) && !isUseFieldset()) { @@ -334,33 +337,56 @@ public class InternalFrameTag extends AbstractHtmlElementTag { tagWriter.startTag("div"); } tagWriter.writeAttribute(CLASS_ATTRIBUTE, "box-header"); - - writeBoxTitle(label); + if (!isToolBoxLeftAligned()) { + writeBoxTitle(label); + } tagWriter.startTag("div"); - tagWriter.writeAttribute(CLASS_ATTRIBUTE, "box-tools pull-right"); - int ctr = 1; - for (Iterator i = commandList.iterator(); i.hasNext();) { - FrameCommandTag tag = i.next(); - processBootstrapCommand(tag, ctr++); - } + if (isToolBoxLeftAligned()) { + tagWriter.writeAttribute(CLASS_ATTRIBUTE, "box-tools pull-left"); + if (isCollapsable()) { + writeHeaderWidget("collapse", getInitialState().equalsIgnoreCase("collapsed") ? getPlusCollapseIcon() + : getMinusCollapseIcon(), null, null, null); + } + } else { + tagWriter.writeAttribute(CLASS_ATTRIBUTE, "box-tools pull-right"); + } + if (!isToolBoxLeftAligned()) { + int ctr = 1; + for (Iterator i = commandList.iterator(); i.hasNext();) { + FrameCommandTag tag = i.next(); + processBootstrapCommand(tag, ctr++); + } + } if (!StringUtils.isEmpty(getModes())) { writeModesWidget(); } - if (isCollapsable()) { - writeHeaderWidget("collapse", getInitialState().equalsIgnoreCase("collapsed") ? "fa-plus" : "fa-minus", null, null, null); + if (!isToolBoxLeftAligned()) { + if (isCollapsable()) { + writeHeaderWidget("collapse", getInitialState().equalsIgnoreCase("collapsed") ? "fa-plus" : "fa-minus", + null, null, null); + } } if (isCloseable()) { writeHeaderWidget("remove", "fa-times", null, null, null); } - tagWriter.endTag(true); //div box-tools + tagWriter.endTag(true); // div box-tools - tagWriter.endTag(true); //legend or div + if (isToolBoxLeftAligned()) { + writeBoxTitle(label); + int ctr = 1; + for (Iterator i = commandList.iterator(); i.hasNext();) { + FrameCommandTag tag = i.next(); + processBootstrapCommand(tag, ctr++); + } + } + + tagWriter.endTag(true); // legend or div } private void writeBoxTitle(String label) throws JspException { @@ -405,8 +431,9 @@ public class InternalFrameTag extends AbstractHtmlElementTag { hasOneModeFor = modeFors.length == 1; hasMoreModeFor = modeFors.length > 1; } - - String name = "button.submit.search?listViewMode=" + mode + (hasOneModeFor ? "&listViewModeFor=" + modeFors[0] : ""); + + String name = "button.submit.search?listViewMode=" + mode + + (hasOneModeFor ? "&listViewModeFor=" + modeFors[0] : ""); tagWriter.startTag("div"); tagWriter.writeAttribute("class", "btn-group"); @@ -415,12 +442,13 @@ public class InternalFrameTag extends AbstractHtmlElementTag { tagWriter.writeAttribute("name", name); tagWriter.writeAttribute("id", "button_submit_search_listViewMode_" + mode); tagWriter.writeAttribute("class", "btn btn-primary btn-sm"); - tagWriter.writeAttribute("title", getRequestContext().getMessage(mode + ".view.mode.title", mode + " view mode")); + tagWriter.writeAttribute("title", + getRequestContext().getMessage(mode + ".view.mode.title", mode + " view mode")); if (hasMoreModeFor) { tagWriter.writeAttribute("data-toggle", "dropdown"); } - + String icon = "fa-" + mode; if ("list".equals(mode)) { icon = "fa-table"; @@ -439,16 +467,16 @@ public class InternalFrameTag extends AbstractHtmlElementTag { } tagWriter.startTag("i"); tagWriter.writeAttribute("class", "fa " + icon); - tagWriter.endTag(true); //i + tagWriter.endTag(true); // i if (hasMoreModeFor) { tagWriter.appendValue(" "); tagWriter.startTag("span"); tagWriter.writeAttribute("class", "caret"); - tagWriter.endTag(true); //span + tagWriter.endTag(true); // span } - tagWriter.endTag(true); //button + tagWriter.endTag(true); // button if (hasMoreModeFor) { tagWriter.startTag("ul"); @@ -462,30 +490,42 @@ public class InternalFrameTag extends AbstractHtmlElementTag { tagWriter.startTag("li"); tagWriter.startTag("a"); tagWriter.writeAttribute("href", "search?listViewMode=" + mode + "&listViewModeFor=" + trimmedModeFor); - tagWriter.writeAttribute("title", getRequestContext().getMessage("view.mode.for.title", new String[] {fieldLabel}, mode + " view mode on " + trimmedModeFor)); - tagWriter.appendValue(getRequestContext().getMessage("view.mode.for.label", new String[] {fieldLabel}, "for " + trimmedModeFor)); - - tagWriter.endTag(true); //a - tagWriter.endTag(true); //li + tagWriter.writeAttribute("title", getRequestContext().getMessage("view.mode.for.title", + new String[] { fieldLabel }, mode + " view mode on " + trimmedModeFor)); + tagWriter.appendValue(getRequestContext().getMessage("view.mode.for.label", new String[] { fieldLabel }, + "for " + trimmedModeFor)); + + tagWriter.endTag(true); // a + tagWriter.endTag(true); // li } - - tagWriter.endTag(true); //ul + + tagWriter.endTag(true); // ul } - - tagWriter.endTag(true); //div.btn-group + + tagWriter.endTag(true); // div.btn-group } private String resolveFieldLabel(String trimmedModeFor) { - //Try by prepending label.getFrameId() to the field name + // Try by prepending label.getFrameId() to the field name String result = getRequestContext().getMessage("label." + getFrameId() + "." + trimmedModeFor, trimmedModeFor); return result; } - private void writeHeaderWidget(String widget, String icon, String label, String title, String onClick) throws JspException { - // + private void writeHeaderWidget(String widget, String icon, String label, String title, String onClick) + throws JspException { + // tagWriter.startTag("button"); tagWriter.writeAttribute("type", "button"); - tagWriter.writeAttribute("class", "btn btn-primary btn-sm"); + if (isToolBoxLeftAligned()) { + if (!StringUtils.isEmpty(onClick)) { + tagWriter.writeAttribute("class", "btn btn-primary btn-sm pull-right frameButton rightFrameButton"); + } else { + tagWriter.writeAttribute("class", "btn btn-primary btn-sm pull-right frameButton"); + } + } else { + tagWriter.writeAttribute("class", "btn btn-primary btn-sm"); + } if (!StringUtils.isEmpty(title)) { tagWriter.writeAttribute("title", title); } @@ -498,17 +538,18 @@ public class InternalFrameTag extends AbstractHtmlElementTag { tagWriter.writeAttribute("id", getFrameId() + "_" + widget); if (!StringUtils.isEmpty(icon)) { - // + // tagWriter.startTag("i"); tagWriter.writeAttribute("class", "fa " + icon); - tagWriter.endTag(true); //i + tagWriter.endTag(true); // i } if (!StringUtils.isEmpty(label)) { - tagWriter.appendValue(label);; + tagWriter.appendValue(label); + ; } - tagWriter.endTag(true); //button + tagWriter.endTag(true); // button } private void writeStandardFieldsetAndLegend(MessageSource messageSource) throws JspException { @@ -523,7 +564,8 @@ public class InternalFrameTag extends AbstractHtmlElementTag { try { writeOptionalAttributes(tagWriter); } catch (Exception e) { - logger.debug(e + " raised during internal frame rendering. Probably the frame was used out of a BindingResult object resolution. Ignoring..."); + logger.debug(e + + " raised during internal frame rendering. Probably the frame was used out of a BindingResult object resolution. Ignoring..."); } String label = TagUtils.getMessage(getRequestContext(), evaluate("legendLabel", legendLabel)); @@ -547,24 +589,23 @@ public class InternalFrameTag extends AbstractHtmlElementTag { } tagWriter.appendValue(label); tagWriter.endTag(); - + writeFieldsetBanner(messageSource); } - private void writeFieldsetBanner(MessageSource messageSource) - throws JspException { + private void writeFieldsetBanner(MessageSource messageSource) throws JspException { tagWriter.startTag("div"); tagWriter.writeAttribute(CLASS_ATTRIBUTE, "fieldsetBanner"); tagWriter.forceBlock(); - + int ctr = 1; for (Iterator i = commandList.iterator(); i.hasNext();) { FrameCommandTag tag = i.next(); processCommand(tag, ctr++); } - - writeCollapseableCommand(messageSource); - writeCloseableCommand(messageSource); + + writeCollapseableCommand(messageSource); + writeCloseableCommand(messageSource); tagWriter.endTag(); writeClearDiv(); } @@ -576,122 +617,124 @@ public class InternalFrameTag extends AbstractHtmlElementTag { tagWriter.endTag(); } - private void writeCloseableCommand(MessageSource messageSource) - throws JspException { + private void writeCloseableCommand(MessageSource messageSource) throws JspException { if (isCloseable()) { - String msgClose = messageSource.getMessage("label.frame.close", TagUtils.EMPTY_ARRAY, getRequestContext().getLocale()); - TagUtils.safeWrite(pageContext, "| "); - tagWriter.startTag("a"); - tagWriter.writeAttribute("id", "IFCI" + getFrameId()); - tagWriter.writeAttribute("href", "javascript: closeFrame('" + getFrameId() + "')"); - tagWriter.writeAttribute(CLASS_ATTRIBUTE, "close"); - tagWriter.writeAttribute(TITLE_ATTRIBUTE, msgClose); - tagWriter.appendValue(msgClose); - tagWriter.endTag(); - TagUtils.safeWrite(pageContext, " "); - } - } - - private void writeCollapseableCommand(MessageSource messageSource) - throws JspException { + String msgClose = messageSource.getMessage("label.frame.close", TagUtils.EMPTY_ARRAY, + getRequestContext().getLocale()); + TagUtils.safeWrite(pageContext, "| "); + tagWriter.startTag("a"); + tagWriter.writeAttribute("id", "IFCI" + getFrameId()); + tagWriter.writeAttribute("href", "javascript: closeFrame('" + getFrameId() + "')"); + tagWriter.writeAttribute(CLASS_ATTRIBUTE, "close"); + tagWriter.writeAttribute(TITLE_ATTRIBUTE, msgClose); + tagWriter.appendValue(msgClose); + tagWriter.endTag(); + TagUtils.safeWrite(pageContext, " "); + } + } + + private void writeCollapseableCommand(MessageSource messageSource) throws JspException { if (isCollapsable()) { - tagWriter.startTag("span"); - tagWriter.writeAttribute("id", "IFTI" + getFrameId() + "_c"); - tagWriter.writeAttribute(CLASS_ATTRIBUTE, "container"); - tagWriter.forceBlock(); - tagWriter.endTag(); - - if (TagUtils.isMessageCode(getTitle())) { - setTitle(messageSource.getMessage(TagUtils.getMessageCode(getTitle()), TagUtils.EMPTY_ARRAY, getTitle(), getRequestContext().getLocale())); - } - String trottleClass; - if (getInitialState() != null && getInitialState().equalsIgnoreCase("collapsed")) { - trottleClass = "collapsed"; - } else { - trottleClass = "expanded"; - } - - addComplexAttribute("IFTI" + getFrameId(), - "javascript: switchFrameLayout('" + getFrameId() + "', true)", - messageSource.getMessage("label.frame.collapseExpand", new String[] {getTitle()}, getRequestContext().getLocale()), - messageSource.getMessage("label.frame.collapseExpandTitle", new String[] {getTitle()}, getRequestContext().getLocale()), - "trottle " + trottleClass); - } - } - - private void addComplexAttribute(String property, String href, String name, String title, String className) throws JspException { - tagWriter.startTag("script"); - tagWriter.writeAttribute("type", "text/JavaScript"); - - StringBuffer scriptContent = new StringBuffer("AddLoadEvent(function() { initInternalFrameField(\""); - - scriptContent.append(property).append("\""); - - if (href != null) { - scriptContent.append(", \"").append(href).append("\""); - } else { - scriptContent.append(",undefined "); - } - if (name != null) { - scriptContent.append(", \"").append(name).append("\""); - } else { - scriptContent.append(",undefined "); - } - if (title != null) { - scriptContent.append(", \"").append(StringEscapeUtils.escapeJavaScript(title)).append("\""); - } else { - scriptContent.append(",undefined "); - } - if (className != null) { - scriptContent.append(", \"").append(className).append("\""); - } else { - scriptContent.append(",undefined "); - } - scriptContent.append(");"); - - tagWriter.appendValue(scriptContent.toString()); - - tagWriter.appendValue("})"); - tagWriter.endTag(); + tagWriter.startTag("span"); + tagWriter.writeAttribute("id", "IFTI" + getFrameId() + "_c"); + tagWriter.writeAttribute(CLASS_ATTRIBUTE, "container"); + tagWriter.forceBlock(); + tagWriter.endTag(); + + if (TagUtils.isMessageCode(getTitle())) { + setTitle(messageSource.getMessage(TagUtils.getMessageCode(getTitle()), TagUtils.EMPTY_ARRAY, getTitle(), + getRequestContext().getLocale())); + } + String trottleClass; + if (getInitialState() != null && getInitialState().equalsIgnoreCase("collapsed")) { + trottleClass = "collapsed"; + } else { + trottleClass = "expanded"; + } + + addComplexAttribute("IFTI" + getFrameId(), "javascript: switchFrameLayout('" + getFrameId() + "', true)", + messageSource.getMessage("label.frame.collapseExpand", new String[] { getTitle() }, + getRequestContext().getLocale()), + messageSource.getMessage("label.frame.collapseExpandTitle", new String[] { getTitle() }, + getRequestContext().getLocale()), + "trottle " + trottleClass); + } + } + + private void addComplexAttribute(String property, String href, String name, String title, String className) + throws JspException { + tagWriter.startTag("script"); + tagWriter.writeAttribute("type", "text/JavaScript"); + + StringBuffer scriptContent = new StringBuffer("AddLoadEvent(function() { initInternalFrameField(\""); + + scriptContent.append(property).append("\""); + + if (href != null) { + scriptContent.append(", \"").append(href).append("\""); + } else { + scriptContent.append(",undefined "); + } + if (name != null) { + scriptContent.append(", \"").append(name).append("\""); + } else { + scriptContent.append(",undefined "); + } + if (title != null) { + scriptContent.append(", \"").append(StringEscapeUtils.escapeJavaScript(title)).append("\""); + } else { + scriptContent.append(",undefined "); + } + if (className != null) { + scriptContent.append(", \"").append(className).append("\""); + } else { + scriptContent.append(",undefined "); + } + scriptContent.append(");"); + + tagWriter.appendValue(scriptContent.toString()); + + tagWriter.appendValue("})"); + tagWriter.endTag(); } private void processCommand(FrameCommandTag tag, int ctr) throws JspException { - if (tag.getAction().startsWith("javascript:")) { - tagWriter.startTag("span"); - tagWriter.writeAttribute("id", "IFTI" + getFrameId() + ctr + "_c"); - tagWriter.writeAttribute(CLASS_ATTRIBUTE, "container"); - tagWriter.forceBlock(); - tagWriter.endTag(); - addComplexAttribute("IFTI" + getFrameId() + ctr, tag.getAction(), tag.getLabel(), tag.getTitle(), null); - } else { - TagUtils.safeWrite(pageContext, "| "); - tagWriter.startTag("a"); - tagWriter.writeAttribute("href", tag.getAction()); - tagWriter.writeAttribute(TITLE_ATTRIBUTE, tag.getTitle()); - tagWriter.appendValue(tag.getLabel()); - tagWriter.endTag(); - TagUtils.safeWrite(pageContext, " "); - } + if (tag.getAction().startsWith("javascript:")) { + tagWriter.startTag("span"); + tagWriter.writeAttribute("id", "IFTI" + getFrameId() + ctr + "_c"); + tagWriter.writeAttribute(CLASS_ATTRIBUTE, "container"); + tagWriter.forceBlock(); + tagWriter.endTag(); + addComplexAttribute("IFTI" + getFrameId() + ctr, tag.getAction(), tag.getLabel(), tag.getTitle(), null); + } else { + TagUtils.safeWrite(pageContext, "| "); + tagWriter.startTag("a"); + tagWriter.writeAttribute("href", tag.getAction()); + tagWriter.writeAttribute(TITLE_ATTRIBUTE, tag.getTitle()); + tagWriter.appendValue(tag.getLabel()); + tagWriter.endTag(); + TagUtils.safeWrite(pageContext, " "); + } } private void processBootstrapCommand(FrameCommandTag tag, int ctr) throws JspException { - if (tag.getAction().startsWith("widget:")) { - String dataWidget = tag.getAction().substring("widget:".length()).trim(); - writeHeaderWidget(dataWidget, null, tag.getLabel(), tag.getTitle(), null); - } else if (tag.getAction().startsWith("javascript:")) { - String onClick = tag.getAction().substring("javascript:".length()).trim(); - writeHeaderWidget("command_" + ctr, null, tag.getLabel(), tag.getTitle(), onClick); - } else { - if (ctr > 1) { - TagUtils.safeWrite(pageContext, "| "); - } - tagWriter.startTag("a"); - tagWriter.writeAttribute("href", tag.getAction()); - tagWriter.writeAttribute(TITLE_ATTRIBUTE, tag.getTitle()); - tagWriter.appendValue(tag.getLabel()); - tagWriter.endTag(); - TagUtils.safeWrite(pageContext, " "); - } + if (tag.getAction().startsWith("widget:")) { + String dataWidget = tag.getAction().substring("widget:".length()).trim(); + writeHeaderWidget(dataWidget, null, tag.getLabel(), tag.getTitle(), null); + } else if (tag.getAction().startsWith("javascript:")) { + String onClick = tag.getAction().substring("javascript:".length()).trim(); + writeHeaderWidget("command_" + ctr, null, tag.getLabel(), tag.getTitle(), onClick); + } else { + if (ctr > 1) { + TagUtils.safeWrite(pageContext, "| "); + } + tagWriter.startTag("a"); + tagWriter.writeAttribute("href", tag.getAction()); + tagWriter.writeAttribute(TITLE_ATTRIBUTE, tag.getTitle()); + tagWriter.appendValue(tag.getLabel()); + tagWriter.endTag(); + TagUtils.safeWrite(pageContext, " "); + } } /** @@ -700,28 +743,30 @@ public class InternalFrameTag extends AbstractHtmlElementTag { */ @Override public int doEndTag() throws JspException { - MessageSource messageSource = getRequestContext().getMessageSource(); - writeGoTopLink(messageSource); + MessageSource messageSource = getRequestContext().getMessageSource(); + writeGoTopLink(messageSource); - tagWriter.endTag(); - tagWriter.endTag(); + tagWriter.endTag(); + tagWriter.endTag(); return EVAL_PAGE; } private void writeGoTopLink(MessageSource messageSource) throws JspException { if (isGoTopLink()) { - String goToTopLink = messageSource.getMessage("label.frame.goToTopLink", TagUtils.EMPTY_ARRAY, getRequestContext().getLocale()); - String goToTopLinkTitle = messageSource.getMessage("label.frame.goToTopLinkTitle", TagUtils.EMPTY_ARRAY, getRequestContext().getLocale()); - tagWriter.startTag("div"); - tagWriter.writeAttribute(CLASS_ATTRIBUTE, "goToTop"); - tagWriter.startTag("a"); - tagWriter.writeAttribute("href", "#content"); - tagWriter.writeAttribute("title", goToTopLinkTitle); - tagWriter.appendValue(goToTopLink); - tagWriter.endTag(); - tagWriter.endTag(); - } + String goToTopLink = messageSource.getMessage("label.frame.goToTopLink", TagUtils.EMPTY_ARRAY, + getRequestContext().getLocale()); + String goToTopLinkTitle = messageSource.getMessage("label.frame.goToTopLinkTitle", TagUtils.EMPTY_ARRAY, + getRequestContext().getLocale()); + tagWriter.startTag("div"); + tagWriter.writeAttribute(CLASS_ATTRIBUTE, "goToTop"); + tagWriter.startTag("a"); + tagWriter.writeAttribute("href", "#content"); + tagWriter.writeAttribute("title", goToTopLinkTitle); + tagWriter.appendValue(goToTopLink); + tagWriter.endTag(); + tagWriter.endTag(); + } } /** @@ -730,7 +775,7 @@ public class InternalFrameTag extends AbstractHtmlElementTag { @Override public void doFinally() { super.doFinally(); - + setCssClass(null); this.cmdAction1 = null; this.cmdLabel1 = null; @@ -745,16 +790,106 @@ public class InternalFrameTag extends AbstractHtmlElementTag { this.cmdLabel4 = null; this.cmdTitle4 = null; this.frameId = null; - this.legendLabel = null; - this.collapsable = false; - this.closeable = false; - this.goTopLink = false; - this.initialState = "expanded"; - this.useFieldset = true; + this.legendLabel = null; + this.collapsable = false; + this.closeable = false; + this.goTopLink = false; + this.initialState = "expanded"; + this.useFieldset = true; this.commandList = new ArrayList(); this.tagWriter = null; this.modes = null; this.style = STYLE_PRIMARY; + this.toolBoxAlign = null; + this.setCustomCollapseIcon(false); + } + + public String getToolBoxAlign() { + return toolBoxAlign; + } + + public void setToolBoxAlign(String toolBoxAlign) { + this.toolBoxAlign = toolBoxAlign; + } + + /** + * Controlla se si č scelto di avere la tooBox a sinistra invece che a destra. + * L'impostazione čuņ essere globale mediante la proprietą frame.toolBox.align + * in ApplicationResource o specifica nel frame + * + * @author Vittorio Niespolo + * + * @return + */ + private boolean isToolBoxLeftAligned() { + String globalToolBoxAlign = null; + + try { + globalToolBoxAlign = getRequestContext().getMessage("frame.toolBox.align"); + } catch (Exception e) { + + } + + if ("left".equals(globalToolBoxAlign) && !"right".equals(getToolBoxAlign())) { + return true; + } + return "left".equals(getToolBoxAlign()); + } + + /** + * Ritorna il valore di una properties presente nel file Application.properties + * del progetto oppure null se non presente + * + * @author Vittorio Niespolo + * + * @param key + * @return + */ + public String getProperty(String key) { + try { + return getRequestContext().getMessage(key); + } catch (Exception e) { + return null; + } } + /** + * Ritorna l'icona scelta per il frame collapsabile quando č aperto + * + * @author Vittorio Niespolo + * + * @return + */ + public String getMinusCollapseIcon() { + String minusCollapseIcon = getProperty("frame.collapseIcon.minus"); + + if (minusCollapseIcon != null && isCustomCollapseIcon()) { + return minusCollapseIcon; + } + return "fa-minus"; + } + + /** + * Ritorna l'icona scelta per il frame collapsabile quando č chiuso + * + * @author Vittorio Niespolo + * + * @return + */ + public String getPlusCollapseIcon() { + String plusCollapseIcon = getProperty("frame.collapseIcon.plus"); + + if (plusCollapseIcon != null && isCustomCollapseIcon()) { + return plusCollapseIcon; + } + return "fa-plus"; + } + + public boolean isCustomCollapseIcon() { + return customCollapseIcon; + } + + public void setCustomCollapseIcon(boolean customCollapseIcon) { + this.customCollapseIcon = customCollapseIcon; + } } diff --git a/voila-runtime-springmvc/src/main/java/it/mice/voila/runtime/springmvc/taglibs/TabsTag.java b/voila-runtime-springmvc/src/main/java/it/mice/voila/runtime/springmvc/taglibs/TabsTag.java index 85a25acccbdc19dfecd177ddccbddd41ee0e5be1..dd7e9656cc90d08a728140bdb506246439734d80 100644 --- a/voila-runtime-springmvc/src/main/java/it/mice/voila/runtime/springmvc/taglibs/TabsTag.java +++ b/voila-runtime-springmvc/src/main/java/it/mice/voila/runtime/springmvc/taglibs/TabsTag.java @@ -26,11 +26,26 @@ public class TabsTag extends AbstractHtmlElementTag { private static final long serialVersionUID = 1L; private Collection tabs; + private String tabId = ""; private String currentTab = null; private String urlTemplate = null; private String onClick = null; private boolean wizard = false; + /** + * @return the tabId + */ + public String getTabId() { + return tabId; + } + + /** + * @param tabId the tabId to set + */ + public void setTabId(String tabId) { + this.tabId = tabId; + } + /** * @return the type */ @@ -217,8 +232,8 @@ public class TabsTag extends AbstractHtmlElementTag { private void writeBootstrapOutput(TagWriter tagWriter) throws JspException { tagWriter.startTag("ul"); - tagWriter.writeAttribute("id", "tabPane"); - tagWriter.writeAttribute("class", "nav nav-tabs"); + tagWriter.writeAttribute("id", "tabPane" + getTabId()); + tagWriter.writeAttribute("class", "nav nav-tabs " + getTabId()); Iterator i = getTabs().iterator(); int ctr = 0; @@ -254,7 +269,7 @@ public class TabsTag extends AbstractHtmlElementTag { //writeImage(tagWriter, tabInfoBean, title, true, true, className, ctr, stripedTitle); tagWriter.startTag("a"); - tagWriter.writeAttribute("id", "tab_" + ctr); + tagWriter.writeAttribute("id", "tab_" + getTabId() + ctr); tagWriter.writeAttribute("href", "#"); if (stripedTitle != null) { tagWriter.writeAttribute("alt", stripedTitle); @@ -280,7 +295,7 @@ public class TabsTag extends AbstractHtmlElementTag { if (!isWizard()) { tagWriter.startTag("a"); } - tagWriter.writeAttribute("id", "tab_" + ctr); + tagWriter.writeAttribute("id", "tab_" + getTabId() + ctr); if (stripedTitle != null) { tagWriter.writeAttribute("title", stripedTitle); } @@ -355,7 +370,7 @@ public class TabsTag extends AbstractHtmlElementTag { tagWriter.writeAttribute("alt", stripedTitle); tagWriter.writeAttribute("title", stripedTitle); } - tagWriter.writeAttribute("id", "tab_image" + ctr); + tagWriter.writeAttribute("id", "tab_image" + getTabId() + ctr); tagWriter.endTag(); } else { tagWriter.startTag("input"); @@ -366,7 +381,7 @@ public class TabsTag extends AbstractHtmlElementTag { tagWriter.writeAttribute("alt", stripedTitle); tagWriter.writeAttribute("title", stripedTitle); } - tagWriter.writeAttribute("id", "tab_image" + ctr); + tagWriter.writeAttribute("id", "tab_image" + getTabId() + ctr); tagWriter.endTag(); } @@ -424,14 +439,14 @@ public class TabsTag extends AbstractHtmlElementTag { } String urlTemplate = (getUrlTemplate() != null ? getUrlTemplate() : "{currentUrl}"); String result = formatUrl(urlTemplate, baseUri, contextPath, tabInfoBean); - result += "?tabIndex=" + ctr; - result += "&jumpTo=tab_" + ctr; + result += "?tabIndex" + getTabId() + "=" + ctr; + result += "&jumpTo=tab_" + getTabId() + ctr; if (tabInfoBean.getOtherParams() != null) { result += "&" + tabInfoBean.getOtherParams(); } //TagUtils.getSecuritySessionBean().addFormField("currentTab", tabInfoBean.getTabName(), "hidden"); - TagUtils.getSecuritySessionBean().addFormField("jumpTo", "tab_" + ctr, "hidden"); + TagUtils.getSecuritySessionBean().addFormField("jumpTo", "tab_" + getTabId() + ctr, "hidden"); return result; } @@ -454,6 +469,7 @@ public class TabsTag extends AbstractHtmlElementTag { public void doFinally() { super.doFinally(); + setTabId(""); setType(null); setTabs(null); setCurrentTab(null); diff --git a/voila-runtime-springmvc/src/main/resources/META-INF/voila-runtime.tld b/voila-runtime-springmvc/src/main/resources/META-INF/voila-runtime.tld index c357b2a28b2cece098115ad1aae2d4cc74543ad0..7727d7e91ea60765c60d46469be98ef7f0ca34c2 100644 --- a/voila-runtime-springmvc/src/main/resources/META-INF/voila-runtime.tld +++ b/voila-runtime-springmvc/src/main/resources/META-INF/voila-runtime.tld @@ -330,6 +330,18 @@ false true + + Tool Box Align + toolBoxAlign + false + true + + + Custom Collapse Icon + customCollapseIcon + false + true + @@ -2328,6 +2340,12 @@ tabs it.mice.voila.runtime.springmvc.taglibs.TabsTag empty + + Id of the Tabs Pane + tabId + false + true + Path to property for data binding tabs