struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Cancro <DCan...@bridgespan.com>
Subject RE: Tab Libraries? Bah!
Date Wed, 24 Apr 2002 20:18:58 GMT
I kind of agree with you.

The homemade framework that's best separated code from html for me uses
pages that look something like this:

<%  
// Readable Programming Section
form1 declaration as a java class that contains as much of the page-specific
(and only page-specific) java as possible
	widget1 declaration & addition to form1 widgets collection
		widget1.setProp
		widget1.setProp
		...
	widget2 declaration & addition to form1 widgets collection
		widget2.setProp
		widget2.setProp
		...

// conditional widget.setProps

// End Readable Programming Section
%>



<!-- HTML Section -->
<html>
<body>
<form>
<!-- misc html -->
	<%=form1.write("WIDGET1")%>
<!-- misc html -->
	<%=form1.write("WIDGET2")%>
<!-- misc html -->
<form>
</body>
</html>
<!-- End HTML Section -->



My self-imposed rule is that the only scriptlets I allow in the HTML section
are 
1) these little "write widget" ones where all passed parameters are
constants, 
2) iterators, and 
3) conditional-section-display/hide "if" statements.  

All other code goes in the "Programming Section" or in the form1 java class.

-Dan



> -----Original Message-----
> From: Joe Osowski [mailto:josowski@fulltilt.com]
> Sent: Wednesday, April 24, 2002 12:15 PM
> To: 'Struts Users Mailing List'
> Subject: Tab Libraries? Bah!
> 
> 
> <bitchSession>
> This kind of thing has really bothered me about Tag libs.  
> The whole point
> of them is to keep HTML code as simple and clean as possible right?  
> 
> But if you have to break down and use the <%%> snippets 
> inline, does it not
> make the whole process self defeating?  In my mind using <%%> 
> snippets and
> tag libraries is more confusing then just using snippets 
> alone, spaghetti
> code be damned. 
> 
> We're trying to take the programmer out of the equation, but 
> as long as the
> tag libraries are implemented half ass, your not going to do 
> anything but
> make the whole process more confusing and frustrating.
> 
> </bitchSession>
> 
> Thoughts?
> 
> 
> -----Original Message-----
> From: Galbreath, Mark [mailto:Galbreath@tessco.com]
> Sent: Wednesday, April 24, 2002 2:44 PM
> To: 'Struts Users Mailing List'
> Subject: RE: html:select how to use it?
> 
> 
> Here's a simple example of how I retrieve a List of years to 
> populate a
> dropdown list:
> 
> <html:select property="ccExpYear" styleId="ccExpYear">
>   <html:option value="0">Year</html:option>
>   <logic:iterate id="expYear" name="listExpYears" scope="session">
>     <html:option value="<%= ( String) expYear %>">
>        <%= expYear %>
>     </html:option>
>   </logic:iterate>
> </html:select>
> 
> 1.  The html:select property is a property in your bean, if 
> one exists.
> 2.  styleId is just the HTML reference if you want to get a 
> value with, say
> JavaScript.
> 3.  The first html:option is the default "selected" option 
> that displays.
> 4.  The logic:iterate id is arbitrary but required to 
> reference the list's
> elements.
> 5.  iterate name is the name of my ArrayList of years that I 
> assigned to a
> session
>     attribute in my action class:
> 
>    List listExpYears = new ArrayList();
>    for( int k = 1; k < 11; k++) {
>          listExpYears.add(( new Integer( 2000 + 
>              Calendar.getInstance().YEAR + k))
>              .toString());
>    }
>    request.getSession().setAttribute( 
>          "listExpYears", listExpYears);
> 
> 6. In html:option value, remember to cast the List objects to 
> strings as
> Struts is expecting a string.
> 
> Easy as pie, eh?
> 
> Mark
> 
> -----Original Message-----
> From: Roshan Paiva [mailto:roshanp@erunway.com]
> Sent: Wednesday, April 24, 2002 3:17 PM
> 
> > Hi...
> > 
> > Could anyone pls tell me how to populate a dropdown list 
> using struts
> > tag libraries.
> > 
> > I have an arraylist of databeans.. The dropdown list should skim
> > through each item in the arraylist and take the value of
> > databean.getFirstValue() (or the firstValue property of the data
> > bean). I believe the tag is html:select. However I am not certain on
> > how to use it.
> > 
> > Kind Regards
> > Roshan
> > 
> 
> --
> To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:   
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message