On May 15, 2009, at 7:28 AM, Paul C wrote:
> Stripes is a great framework in its common sense approach to form
> processing and
> action handling but as a newbie I'm ready to give up on it just like
> so many
> other java frameworks.
>
> Someone please tell me I'm wrong but here are my main two complaints:
>
> 1) No extention library with standard components for common tasks
> such as
> breadcrumbs and menus? Please don't preach to me about stripes
> stressing
> simplicity and that I can easily create a custom tag or use
> stripes:layout-component to do these things.
But...you CAN do this.
Here;
public class Crumb {
String title;
String linkParams;
Class actionClass;
public Crumb(Class actionClass, String title, String link) {
this.actionClass = actionClass;
this.title = title;
this.link = linkParams;
}
public Class getActionClass() { return actionClass; };
public String getTitle() { return title; }
public String getLinkParams() { return linkParams; }
}
public CrumbActionBean implements ActionBean {
private ActionBeanContext context;
public ActionBeanContext getContext() {
return context;
}
public void setContext(ActionBeanContext actionBeanContext) {
this.context = actionBeanContext;
}
public Collection<Crumbs> getCrumbs() {
List<Crumbs> crumbs =
context.getRequest().getSession().getAttribute("crumbs");
if (crumbs == null) {
crumbs = new ArrayList<Crumb>();
}
return crumbs;
}
public void addCrumb(String title, String linkParams) {
List<Crumb> newCrumbs = new ArrayList<Crumb>;
for(Crumb c : getCrumbs()) {
if (this.getClass().equals(c.getActionClass()) {
break;
}
newCrumbs.add(c);
}
newCrumbs.add(this.getClass(), title, linkParams);
context.getRequest().getSession().setAttribute("crumbs",
newCrumbs);
}
}
public YourActionBean extends CrumbActionBean {
@Default
public Resolution view() {
addCrumb("Your Action Page", null);
return new ForwardResolution("youpage.jsp");
}
}
crumbs.tag
<%...@tag description="Cookie crumb tag" pageEncoding="UTF-8"%>
<%@ include file="/taglibs.jsp" %>
<c:forEach items="${action.crumbs}" var="c" varStatus="status">
<s:url var="url" beanclass="${c.actionClass}"/>
<c:if test="${!empty c.linkParams}">
<c:set var="url" value="${url}?${c.linkParams}"/>
</c:if>
<a class="crumb" href="${url}">${c.title}</a>
<c:if test="${!status.last}">
<img src="crumbarrow.png" class="crumbarrow"/>
</c:if>
</c:forEach>
To use it, just put: <t:crumbs/> on your page. Easy. (No, really, this
is easy.)
> Common sense says there should be a standard toolkit to do these
> things.
Who's standard. My standard? Did you like my crumb implementation?
> ASP.NET makes it look so easy but for
> some reason java frameworks never address common sense issues like
> this in
> respectable way.
ASP.NET IS easy. ASP.NET is amazing. At least, until it's not. At
least until all of a sudden that incremental bit of "how hard can it
be" functionality that you want, that's just outside the "standard"
they provide, requires you to effectively abandon some segment of
functionality entirely. Simple example, .NET has a nice little set of
"standard" "security" components. Login in, Log out, Change Password,
Password recovery. If you're content with them, happy day. But as soon
as you need something else, like say locking an account that has
failed login after N times, well....good bye. It's all gone. You get
to rewrite the ENTIRE THING from scratch.
So, just curious who's standard you'd be happy with.
> Or at least why can't stripes:link behave like wicket:link so
> you don't have to waste hours deciding the best way to make a link
> on a menu
> look different or "selected" if it points to the current page?
Because that's not what s:link does. It's just an <a .. > tag and s:url.
> 2) Something like ASP.NET MasterPages or Wicket extendable panels
> seems more
> direct and efficient to create page layouts. With Stripes I'm
> finding that I
> need 3 or 4 layers of nested layouts with a bunch of overly verbose
> JSTL. Or
> that I need a bunch of helper classes and running action beans from a
> layout-component and using jsp:includes just to set up a standard
> page layout
> (header, menu, left panel, main panel, footer, etc...).
Huh. That's fascinating being that I don't have to do any of those
things. Mind, I've not used the Stripes layout tags.
> FreeMarker helps avoid
> these things but I'm not finding good examples of advanced
> FreeMarker work with
> Stripes. Also, you can't easily view page compositions in a visual
> jsp or html
> editor with Stripes the way you can with Facelets, Wicket,
> MasterPages, or IBM
> RAD proprietary templating solutions.
ASP.NET does that graphical "rich authoring" "view in the editor"
style of page creation. I found that, basically, with "intermediate"
pages, it basically broke down to where it was just easier to author
things in HTML.
But that's me.
All of those concerns you talk about have 2 fundamental problems for a
general purpose piece of kit like Stripes.
First, is they almost all deal with presentation and user interaction.
A space that is SO VAST, in terms of design, desire, and end user
experience, that it's effectively impossible to draw any reasonable
circle around to corral even the "basics" in any meaningful manner.
Ajax? No Ajax? What models do you use? How do you interact with those
models? What about styles, style sheets, and cross browser
compatibility for anything even moderately complex? "Why do my cookie
crumbs wrap? Why don't my cookie crumbs wrap? The icon is too big, too
small, wrong color, doesn't work in frames? why isn't it stored in a
cookie? I can't use cookies! I don't want sessions! Why won't it
failover? Why does the cookie crumb require 100K in Javascript?"
That's a lot of agony for a simple list of links, and it's a lot of
agony when it's not simple.
Which leads to the second problem. Complexity. Do one thing well, and
you can control complexity. Do something to please a specific party,
and you can control complexity. Do "everything" for "everybody" and
you get...um...a mess. A very opaque and hard to use and understand
mess.
The greatest benefit of Stripes is that it works with two fundamental
things that just so happen to be pretty common in Java web
development. It works GREAT with JSPs/JSTL, and it works GREAT with
HttpServletRequests. And I mean great. Downright painless.
Transitioning from an HTTP request to an Action is seamless.
Transitioning from an Action to a JSP page is also seamless.
This is a testament to Stripes Binding model, and a testament to the
JSTL/EL designers.
Stripes provides very little black magic, and what black magic is does
provide works very, very well. The beauty of Stripes is that after
perhaps some early teething problems, you pretty much never fight the
framework. It falls out of sight, and out of mind, and just works. I
scream and yell at my IDE, or at my app server, at JPA, or some stupid
class path problem, but I never shout and yell at Stripes. It's solid,
it's consistent, and it specializes at "doing the right thing".
If I have a problem with an Action, 99% of the time it's staring at me
in the request. It's almost always my request that's wrong, due to
something I did (forgot something, misspelled something, etc.). Rather
than "Oh god, there goes Stripes again /facepalm." or "WTF Stripes!".
Those characteristics makes Stripes a very solid piece of kit. It's
simplicity and focus keep it solid. Keep it understandable. Keep it
approachable and easily picked up. Stripes is so easy to get started
with, and Freddy's book makes it just SO much better.
On top of these features, Stripes has an almost unique characteristic
of layered and orthogonal complexity. It has the great feature that if
you find you need to peel the onion of the framework to achieve some
extra bit of functionality than the stuff on Page 1 doesn't provide,
you'll find that it truly is an onion of thin layers, and that
underneath the first layer isn't some tangled, impenetrable muck you
need to instantly understand to add your little piece. Many frameworks
look shiny on the surface, but once you breach that surface you find
the abstractions break down and that you need to jump from novice to
expert. The light doesn't get dimmer as you go in, it just suddenly
goes from bright understanding to pitch black and fumbling for
matches, hoping there isn't a gas leak. This is an under appreciated
aspect of the framework that goes unnoticed until you need to peer in
to the depths.
I'm sorry you don't find Stripes to your liking. Sounds like you'd be
happier with a component framework. Component frameworks are great for
those back office applications. People I hold in high regard and have
a lot of respect for really like Wicket. On that criteria alone I
would suggest looking at Wicket if you wish to adopt a component
framework.
IF you want some UI tags or what not, Stripes works great with just
plain old JSP tags. Someone, somewhere, might have some "standard
items" that you'd might like to use. DisplayTag is a very popular grid
tag, for example. It doens't know anything about Stripes, and it works
a treat.
If you decided to stay with Stripes, and feel that you would like to
share some Cookie Crumb tags, or other code that you think would make
Stripes richer and more approachable, feel free to hunt down
StripesStuff, that's where that kind of stuff belongs.
Finally, here's a list page from a personal project. If uses a custom
Tag File tag named, of all things, "page". Tag Files are my hammer of
choice. I recommend them highly to everyone that uses JSP.
<%...@page contentType="text/html"%>
<%...@page pageEncoding="UTF-8"%>
<%@ include file="taglibs.jsp" %>
<t:page title="Age List" page="Ages" section="Catalog">
<s:form action="/AgeList.action">
<dt:table list="${actionBean.ages}" id="obj" class="display"
pagesize="10" requestURI="AgeList.action" sort="list" >
<dt:column class="checkboxcol">
<s:checkbox name="ageIds" value="${obj.id}"
onclick="handleCheckboxRangeSelection(this, event);"/>
</dt:column>
<dt:column property="id" title="Id"/>
<dt:column property="name" title="Name"/>
<dt:column property="minAge" title="Min Age"/>
<dt:column property="maxAge" title="Max Age"/>
<dt:column property="theme" title="Theme"/>
<dt:column>
<s:link href="/Age.action" event="preEdit">
Edit
<s:param name="age.id" value="${obj.id}"/>
</s:link>
</dt:column>
</dt:table>
<div class="buttons">
<s:submit name="addNew" value="Add New"/>
<s:submit name="deleteSelected" value="Delete Selected"/>
</div>
</s:form>
</t:page>
And here's the page tag file for it, you'll see it relies on a couple
of more Tag File tags (header, pageheader, pagefooter).
<%...@tag description="put the tag description here" pageEncoding="UTF-8"%>
<%@ include file="/taglibs.jsp" %>
<%...@attribute name="page" required="false"%>
<%...@attribute name="title" required="true"%>
<%@ attribute name="headers" fragment="true" %>
<%@ attribute name="upperRight" fragment="true" %>
<%...@attribute name="section" required="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
">
<html>
<head>
<t:header title="${title}"/>
<jsp:invoke fragment="headers"/>
</head>
<body>
<div id="contentPanel">
<t:pageheader title="${title}"/>
<c:choose>
<c:when test="${!empty page}">
<t:tabs page="${page}" section="${section}"/>
</c:when>
<c:otherwise>
<hr width="100%" color="#A9A9A9" style="height:
1px;">
</c:otherwise>
</c:choose>
<div id="pageContent">
<table width="100%">
<tr>
<td>
<div class="sectionTitle">${title}</div>
</td>
<jsp:invoke fragment="upperRight"/>
</tr>
</table>
<jsp:doBody/>
</div>
</div>
<t:pagefooter/>
</body>
</html>
These tags are not generic, they're simply refactorings for this
project. In another project, I'd just rewrite them, or start with
these and tweak them.
My pages are pretty simple, this one has a two tiers of tabs (it even
handles the "I'm selected" page problem, that was 4 lines in another
Tag File), simple style sheets, using "Stripes Green" as a color scheme.
What you don't see here is that at the office, the list pages are even
simpler, but offers 3 tiers of database backed, role based navigation
(tabs, submenus, and drop down menus), dynamic task links based on row
seleciton, ajax based paging, sorting, etc, as well as simple and
advanced filtering. Pretty styles, gradients, nice colors, themes,
logos, etc. Yet, at a glance, you'd find those complicated list pages
look much like this one. The actual Action beans aren't super horrible
either. A sophisticated network of tag files and base class Action
Beans do all of the heavy lifting.
And it's all just "plain ol Stripes".
Enjoy your quest.
Regards,
Will Hartung
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users