struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tarek M. Nabil" <>
Subject <html:link> ties the model to the view
Date Wed, 12 Mar 2003 19:26:32 GMT
Hi everyone,

I've been using Struts for a while, and I think it's the best thing since servlets. 

Today, though, I ran into a problem that when I tried to implement with Struts, I found the
solution to be rather dissappointing. Or maybe it's just me, and I couldn't figure out the
best way to do it.

I have a JSP that lists a number of elements, and beside each element, there's a link to another
page where the user can edit this element.

I use a model class to retrieve a Vector of instances from the class that encapsulates that

I use the <logic:iterate> tag to iterate over this Vector and show the elements. When
I tried to implement the link that will point to the page where the element can be edited,
I found out that the <html:link> tag has a strange way of getting the parameters to
be appened to the link. If you want to send more than one parameter then you need to provide
a Map of the parameter names and values.

Since I'm iterating over a collection, the only way to do that is to provide this Map from
the instances in this collection for every element. But that would mean that my model (Class
whose instance is in the Vector) has to know the names of the request parameters I'm sending.
Isn't that some sort of coupling between the model and the web tier? Or am I missing something

I'll provide the code here to help explain my point...I've only included the element in question.

<logic:iterate id="element" name="listSubcategoryForm" property="visibleCategories" type="<cannot
reveal package name>.SubcategoryModel">
	<tr><td><html:link name="element" property="params"
		page="/"><html:img border="0"

So, I need SubcategoryModel to implement a method called getParams() to return a java.util.Map
that contains the request parameters and their values. That would essentially mean that SubcategoryModel
knows the name of the request parameters, which is not that good.

I don't have another way to do it. Can anyone help?

Thanks in advance.

Tarek M. Nabil
Software Engineer
Free Zone, Area 7 (B),
Block (J), Nasr City,
Cairo, Egypt
TEL.: 20-2-2766226

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message