You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mike Whittaker <mi...@ntlworld.com> on 2003/08/21 12:51:16 UTC

tag writing newbie

I have a List of subclasses that need to be iterated over and rendered in
jsp.

I notice that 'instanceof' is a reserved word in jstl, but has not been
implemented yet. So I now feel the need to write a tag.

On 1st glance I thought custom tag would be limited to Strings, but I see
that I can get at Request object.

So I am proposing this sort of thing:

<c:forEach var="list" items="${myList}" varStatus="loop">
<hp:myTag count="${loop.count}" set="type" />
<c:if test="${type == 'mySubClass'}"> <p>Rendering mySubClass</p> </c:if>
...
</c:forEach>

Then in the tag class

List myList = (List)request.getAttribute("myList")
myList.get(//int from loop.count//)
// do is instanceof
// set variable for tag attribute 'set' ie 'type' to a String indicating
subclass

Questions:
0/ Is there a better/easier way to accomplish this?
1/ Can I use EL in my own tags (${loop.count}), if not automatic how?
2/ Is there a simpler way to get at the objects in my List within tag class,
than this?

--
Mike W



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


redirect and post form

Posted by Peter Bliznak <bl...@rogers.com>.
Hi,
I have app which needs to go to external url to make payment.
I am aware of how to redirect but from what I understand it is
not possible to redirect and post. ( only to put parameters to
request). That is not acceptable solution if customer's and account
credential are taken into account.
My  question is : is there ANY solution to this?
I cannot possible be first person running into this scenario.

-- gather info -- post it into hidden fields on next page -- and from there
   it SHOULD get posted to
   external(absolute) URL for proccesing

Any info would be appreaciated

Regards,

Peter



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


RE: tag writing newbie

Posted by Mike Jasnowski <mj...@bea.com>.
>1/ Can I use EL in my own tags (${loop.count}), if not automatic how?

Yes, http://jakarta.apache.org/commons/el/api/index.html

Are you constructing a list of different types? If so that will complicate
things especially if they
have no common characteristics. If they are all of the same type, you should
be able to interate over them with standard JSTL and Struts tags

-----Original Message-----
From: Mike Whittaker [mailto:mike_whittaker@ntlworld.com]
Sent: Thursday, August 21, 2003 6:51 AM
To: Struts List
Subject: tag writing newbie


I have a List of subclasses that need to be iterated over and rendered in
jsp.

I notice that 'instanceof' is a reserved word in jstl, but has not been
implemented yet. So I now feel the need to write a tag.

On 1st glance I thought custom tag would be limited to Strings, but I see
that I can get at Request object.

So I am proposing this sort of thing:

<c:forEach var="list" items="${myList}" varStatus="loop">
<hp:myTag count="${loop.count}" set="type" />
<c:if test="${type == 'mySubClass'}"> <p>Rendering mySubClass</p> </c:if>
...
</c:forEach>

Then in the tag class

List myList = (List)request.getAttribute("myList")
myList.get(//int from loop.count//)
// do is instanceof
// set variable for tag attribute 'set' ie 'type' to a String indicating
subclass

Questions:
0/ Is there a better/easier way to accomplish this?
1/ Can I use EL in my own tags (${loop.count}), if not automatic how?
2/ Is there a simpler way to get at the objects in my List within tag class,
than this?

--
Mike W



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



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