[
http://www.stripesframework.org/jira/browse/STS-417?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Frederic Daoud closed STS-417.
------------------------------
Resolution: Won't Fix
Closing my own issue. There are too many 'if's, 'but's, or 'maybe's involved
and this would end up causing more harm than good, IMO. Let's keep Stripes
simple and straightforward.
> Add boolean 'enabled' (optional) attribute to stripes:link tag
> --------------------------------------------------------------
>
> Key: STS-417
> URL: http://www.stripesframework.org/jira/browse/STS-417
> Project: Stripes
> Issue Type: New Feature
> Components: Tag Library
> Affects Versions: Release 1.5
> Reporter: Frederic Daoud
> Priority: Minor
>
> As discussed in this thread:
> http://thread.gmane.org/gmane.comp.java.stripes.user/4612
> I suggest adding a boolean attribute, 'enabled', to the stripes:link tag.
> This attribute would be optional and true by default. If set to false, the
> tag renders the body but not the link, such that the link appears as plain
> text only. This is useful, for example, to enable links based on some dynamic
> condition, e.g. user rights.
> <stripes:link href="..." enabled="${user.allowed}">Link</stripes:link>
> Very easy to implement, for example, against SVN trunk version 608:
> Index: src/net/sourceforge/stripes/tag/LinkTag.java
> ===================================================================
> --- src/net/sourceforge/stripes/tag/LinkTag.java (revision 608)
> +++ src/net/sourceforge/stripes/tag/LinkTag.java (working copy)
> @@ -31,6 +31,7 @@
> * @author Tim Fennell
> */
> public class LinkTag extends LinkTagSupport implements BodyTag {
> + private boolean enabled = true;
> /**
> * Does nothing.
> @@ -62,13 +63,17 @@
> @Override
> public int doEndTag() throws JspException {
> try {
> - set("href", buildUrl());
> - writeOpenTag(getPageContext().getOut(), "a");
> + if (enabled) {
> + set("href", buildUrl());
> + writeOpenTag(getPageContext().getOut(), "a");
> + }
> String body = getBodyContentAsString();
> if (body != null) {
> getPageContext().getOut().write(body.trim());
> }
> - writeCloseTag(getPageContext().getOut(), "a");
> + if (enabled) {
> + writeCloseTag(getPageContext().getOut(), "a");
> + }
> }
> catch (IOException ioe) {
> throw new StripesJspException("IOException while writing output
> in LinkTag.", ioe);
> @@ -80,6 +85,12 @@
> return EVAL_PAGE;
> }
> + /** Sets the (optional) flag that indicates if the link is enabled. */
> + public void setEnabled(boolean enabled) { this.enabled = enabled; }
> +
> + /** Gets the (optional) flag that indicates if the link is enabled. */
> + public boolean isEnabled() { return enabled; }
> +
> /** Pass through to [EMAIL PROTECTED] LinkTagSupport#setUrl(String)}. */
> public void setHref(String href) { setUrl(href); }
> /** Pass through to [EMAIL PROTECTED] LinkTagSupport#getUrl()}. */
> Index: resources/stripes.tld
> ===================================================================
> --- resources/stripes.tld (revision 608)
> +++ resources/stripes.tld (working copy)
> @@ -807,6 +807,16 @@
> <type>java.lang.Object</type>
> </attribute>
> <attribute>
> + <description>
> + An optional flag indicating whether or not the link should
> be enabled. If set to
> + false, the link is considered to be disabled, and the link
> tags will not be
> + rendered; the link body will be rendered as plain text.
> + Default value is true.
> + </description>
> +
> <name>enabled</name><required>false</required><rtexprvalue>true</rtexprvalue>
> + <type>boolean</type>
> + </attribute>
> + <attribute>
> <description>The character set used to encode the referenced
> page. (HTML Pass-through)</description>
>
> <name>charset</name><required>false</required><rtexprvalue>true</rtexprvalue>
> </attribute>
> What do you think?
> Thanks,
> Freddy
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://www.stripesframework.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development