Thanks for the responses to my question.
I agree totally with what you are saying, to try generating Struts tags from a
Custom tag
is completely the wrong approach - I can see that now (you know, "I see the
light" :-)
Let me explain what I am trying to do, maybe somebody can point me in the right
direction.
My website provides a login capability and each user has a security setting,
this is just a
number (security isn't too complicated). Number 0 can simply browse around and
make
comments etc. Security number 5 is allowed to manage the content, add and
update
database records that contain data that appear on the site. Number 3 is
allowed similar
content management access but only on certain records.
When I display a page that contains some database records I then want to
display
"Update" and "Delete" links next to the appropriate data.
I could use a <logic:greaterThan...> tag to test the value of the security
number and
then display the link if appropriate. This gets more complicated when the
security
number 3 is used, as then I have to test values on the record as well, suddenly
I have
nested <logic:..> tags and the page is starting to look a lot more complicated
than it
should. The other problem with this approach is: "whether a user can update a
record
or not" is a business logic decision and shouldn't be in the interface.
Now, to complicate it even further, security number 2 is allowed to update
records but
uses a different form, in other words, they are only allowed to update certain
values on
the record. Hence I have to vary the link generated in some instances.
I hope you are getting the picture. This is why I was trying to use a custom
tag that
could still interact with my model, call business methods to make security
decisions and
vary the generated link accordingly.
And finally the question: How should I go about writing the "Update" link now
that we all
understand the problem?
Thanks in advance.
Kind regards
mc
On 19 Aug 2005 at 15:30, Craig McClanahan wrote:
> On 8/18/05, Murray Collingwood <[EMAIL PROTECTED]> wrote:
> > Hello all
> >
> > Has anybody successfully used Stuts tags and Custom tags together?
> >
> > For example:
> > Consider a custom tag with the following code:
> > out.println("<html:link action=\"Update.do\">" + entry[ix] +
> > "</html:link>");
> >
>
> Your question doesn't really describe what you are illustrating ...
> which appears to be that you want to dynamically create a *JSP* page,
> then have the page compiled and executed, on every request. You're
> going to find that this solution is not practical, and that you should
> take another approach.
>
> When you first start a webapp, you notice the slight delay when you
> access a JSP page the first time, so that it gets compiled? Even if
> you jumped through all the technical hoops to output a JSP file and
> get it compiled (technically feasible), you're going to be imposing
> that kind of overhead on *every* request, instead of just the first
> request for that page. Even if everything else in your app was
> instantaneous, the response time of your app would be awful.
>
> A far better approach for the particular case you are using here is to
> use either an expression or some subordinate tag to calculate the
> dynamic part of your output. Assume for a moment that your Struts
> action puts the "entry" array into request scope. Now you can do
> something like:
>
> <html:link action="Update.do">
> <c:out value="${entry[3]}"/>
> </html:link>
>
> Of course, the reason you probably want to do this in the first place
> is that you want to create a bunch of links ... so put the same sort
> of structure inside a looping tag (renaming the request scope
> attribute containing your array to be "entries" to be more readable):
>
> <c:forEach var="entry" items="entries">
> <html:link action="Update.do">
> <c:out value="$entry"/>
> </html:link>
> </c:forEach>
>
> The <c:forEach> tag exposes the current element in the array as a page
> scope attribute named by the "var" attribute, and you can therefore
> reference the current element directly inside the loop.
>
> Craig
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.338 / Virus Database: 267.10.13/78 - Release Date: 19/08/2005
>
FOCUS Computing
Mob: 0415 24 26 24
[EMAIL PROTECTED]
http://www.focus-computing.com
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.13/78 - Release Date: 19/08/2005
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]