iiiiiiiiiiii scriptlets....
aren't we considering scriptlets evil? :-)
Leon
On 1/2/07, Martin Gainty <[EMAIL PROTECTED]> wrote:
conceptually you could pull bean:message key and input type when previously
populating Bean properties using the example of LabelValueBean
<%@ page import="java.util.*"%>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/struts-form.tld" prefix="form" %>
<%@ taglib uri="/WEB-INF/jstl-core.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/ragingtorrent.tld" prefix="ap" %>
<%
LinkedList hs=new LinkedList();
for (int i=0;i<10;i++)
{
if(i%2==0) hs.add(new org.apache.struts.util.LabelValueBean(new
Integer(i).toString(),"text");
else hs.add(new org.apache.struts.util.LabelValueBean(new
Integer(i).toString(),"checkbox");
}
pageContext.setAttribute("hs", hs, PageContext.PAGE_SCOPE);
%>
<%
for(int i=0;i<10;i++)
{
%>
<tr>
<td>
<bean:message key="field."+"prop{<%= ((LabelValueBean) hs.get(i)).label
%>"
</td>
<td>
<input type="prop{<%= ((LabelValueBean) hs.get(i)).value %>"
</td>
</tr>
<%
}
%>
Viel Gluck,
Martin --
---------------------------------------------------------------------------
This e-mail message (including attachments, if any) is intended for the use of
the individual or entity to which it is addressed and may contain information
that is privileged, proprietary , confidential and exempt from disclosure. If
you are not the intended recipient, you are notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
---------------------------------------------------------------------------
Le présent message électronique (y compris les pièces qui y sont annexées, le
cas échéant) s'adresse au destinataire indiqué et peut contenir des
renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le
destinataire de ce document, nous vous signalons qu'il est strictement interdit
de le diffuser, de le distribuer ou de le reproduire.
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, January 02, 2007 3:36 PM
Subject: How to reduce redundant form code in JSPs?
> Hi,
>
> My application consists of several forms, all following a common style. Each
> form is rendered using a table. This results in the following code for each
> field:
>
> <tr>
> <td> <bean:message key="field.xxx"> </td>
> <td>
> <html:text property="xxx" readonly="${readonly}" /><br>
> <html:errors property="xxx" /><br>
> </td>
> </tr>
>
> The only variations are the name of the field ("xxx" in the snippet) as well
as
> the field type (in most cases html:text, sometimes html:checkbox). Is there a
> way to reduce this redundant code?
>
> Thanks for your help,
>
> Thorsten
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]