struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan Koppenhofer (JIRA)" <j...@apache.org>
Subject [jira] Created: (WW-1811) Add generic custom tag attributes to pass custom parameters into a tag
Date Tue, 13 Mar 2007 19:04:51 GMT
Add generic custom tag attributes to pass custom parameters into a tag
----------------------------------------------------------------------

                 Key: WW-1811
                 URL: https://issues.apache.org/struts/browse/WW-1811
             Project: Struts 2
          Issue Type: Improvement
          Components: Views
    Affects Versions: 2.0.6
            Reporter: Jonathan Koppenhofer
            Priority: Minor


It would be nice to have a generic struts tag attribute for all tags to pass in custom parameters
into the tag to use within custom templates.

For example. I want to enable field level "mode" capabilites similar to what can be done in
Struts-Layout (http://struts.application-servers.com) for struts 1.1-1.3. This includes the
ability to specify a mode (Editable, ReadOnly. Hidden, etc...) for a field dependent on what
mode (Create, Edit, Read) the page is in. An example struts-tag could be:

<s:textfield key="firstName" somecustommodeattribute="E,E,I"/>

In the example above "E,E,I" stands for... If page is in create mode the field is editable,
if the field is in edit mode the field is ediatble, if the page is in read mode the field
is readonly (inspect)

I extended the simple text.ftl to be like:

<#if parameters.somecustommodeattribute?exists>
  <#assign modeKey = 0/>
  <#if Session.pageMode?exists>
    <#assign modeKey = Session.pageMode?int/>
  </#if>
  <#if Request.pageMode?exists>
    <#assign modeKey = Request.pageMode?int/>
  </#if>
  <#assign fieldMode = parameters.somecustommodeattribute?substring(modeKey,modeKey+1)/>
<#else>
  <#assign fieldMode = "E"/>
</#if>

<#if !(fieldMode = "N") >
	<#if fieldMode = "E" >
		<input type="text"<#rt/>
		 name="${parameters.name?default("")?html}"<#rt/>
		<#if parameters.get("size")?exists>
		 size="${parameters.get("size")?html}"<#rt/>
		</#if>
		<#if parameters.maxlength?exists>
		 maxlength="${parameters.maxlength?html}"<#rt/>
		</#if>
		<#if parameters.nameValue?exists>
		 value="<@s.property value="parameters.nameValue"/>"<#rt/>
		</#if>
		<#if parameters.disabled?default(false)>
		 disabled="disabled"<#rt/>
		</#if>
		<#if parameters.readonly?default(false)>
		 readonly="readonly"<#rt/>
		</#if>
		<#if parameters.tabindex?exists>
		 tabindex="${parameters.tabindex?html}"<#rt/>
		</#if>
		<#if parameters.id?exists>
		 id="${parameters.id?html}"<#rt/>
		</#if>
		<#if parameters.cssClass?exists>
		 class="${parameters.cssClass?html}"<#rt/>
		</#if>
		<#if parameters.cssStyle?exists>
		 style="${parameters.cssStyle?html}"<#rt/>
		</#if>
		<#if parameters.title?exists>
		 title="${parameters.title?html}"<#rt/>
		</#if>
		<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
		<#include "/${parameters.templateDir}/simple/common-attributes.ftl" />
		/>
	<#else>
		<#include "/${parameters.templateDir}/simple/hidden.ftl" />
		<#if fieldMode = "I" >
			<@s.property value="parameters.nameValue"/>
		</#if>
	</#if>
</#if>

Now granted this is a very specific example, but it would just be nice to have a generic parameter
that I can access in my ftl templates.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message