You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mohd Fadhly <fa...@xybase.com> on 2003/09/22 06:04:30 UTC

how to change this logic into tags

hello,

how do i change this scriptlet logic into struts tag,

<%
            ArrayList al = (ArrayList) request.getAttribute("al");

            if (al != null) {
                for (int i=0;i<al.size()/2;i++) {
                    SystemProfileData spd = (SystemProfileData) al.get(i);
                    if (i==0)
                        int topmsg = spd.getSentCount();
%>
    <table border=0 width=100%>
    <tr><td width="20%"><%=spd.getName()%></td>
    <td>
        <table border=0 width=100% cellspacing="0" cellpadding="0">
            <td width="<%=topmsg!=0?spd.getSentCount()*80/topmsg:0%>%"></td>
            <td 
width="<%=topmsg!=0?100-(spd.getSentCount()*80/topmsg):0%>%">><%=spd.getSentCount()%></td>
        </table>
    </td>
    </tr></table>
<%                 }
            }
%>


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


Re: how to change this logic into tags

Posted by Ted Husted <hu...@apache.org>.
Don't! =:)

Put logic in an *Action*, or in this case maybe a business class, and 
place the result in a JavaBean and use the tags to display the result. 
(Or put the logic in the JavaBean that the tags can invoke.) If you want 
to use a MVC architechture, which Struts encourages, the pages are 
viewed as output only devices. Any real processing takes place in an 
Action or in a business class invoked by the Action.

HTH, Ted.

Mohd Fadhly wrote:
> hello,
> 
> how do i change this scriptlet logic into struts tag,
> 
> <%
>            ArrayList al = (ArrayList) request.getAttribute("al");
> 
>            if (al != null) {
>                for (int i=0;i<al.size()/2;i++) {
>                    SystemProfileData spd = (SystemProfileData) al.get(i);
>                    if (i==0)
>                        int topmsg = spd.getSentCount();
> %>
>    <table border=0 width=100%>
>    <tr><td width="20%"><%=spd.getName()%></td>
>    <td>
>        <table border=0 width=100% cellspacing="0" cellpadding="0">
>            <td width="<%=topmsg!=0?spd.getSentCount()*80/topmsg:0%>%"></td>
>            <td 
> width="<%=topmsg!=0?100-(spd.getSentCount()*80/topmsg):0%>%">><%=spd.getSentCount()%></td> 
> 
>        </table>
>    </td>
>    </tr></table>
> <%                 }
>            }
> %>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 

-- 
Ted Husted,
   Junit in Action  - <http://www.manning.com/massol/>,
   Struts in Action - <http://husted.com/struts/book.html>,
   JSP Site Design  - <http://www.amazon.com/exec/obidos/ISBN=1861005512>.

"Get Ready, We're Moving Out!!" - <http://www.clark04.com>



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


RE: how to change this logic into tags

Posted by Mohd Amin Mohd Din <am...@nc.com.my>.
This could/should be put into an Action

/*           ArrayList al = (ArrayList) request.getAttribute("al");

            if (al != null) {
                for (int i=0;i<al.size()/2;i++) {
                    SystemProfileData spd = (SystemProfileData)
al.get(i);
                    if (i==0)
                        int topmsg = spd.getSentCount();
*/

The spd.getSentCount() should give u the correct top message. No need to
count it. But if you can't then you could either create a new property
which shows this or create a bean which you could hold your values

/*           
 <td width="<%=topmsg!=0?spd.getSentCount()*80/topmsg:0%>%"></td>
*/

for writing out properties you could use <bean:write name="beanName"
property="propertyName" />

for html link <html:link >

Look here for more info http://jakarta.apache.org/struts/userGuide/

Amin
-----Original Message-----
From: Mohd Fadhly [mailto:fadhly@xybase.com] 
Sent: Monday, September 22, 2003 12:05 PM
To: Struts Users Mailing List
Subject: how to change this logic into tags

hello,

how do i change this scriptlet logic into struts tag,

<%
            ArrayList al = (ArrayList) request.getAttribute("al");

            if (al != null) {
                for (int i=0;i<al.size()/2;i++) {
                    SystemProfileData spd = (SystemProfileData)
al.get(i);
                    if (i==0)
                        int topmsg = spd.getSentCount();
%>
    <table border=0 width=100%>
    <tr><td width="20%"><%=spd.getName()%></td>
    <td>
        <table border=0 width=100% cellspacing="0" cellpadding="0">
            <td
width="<%=topmsg!=0?spd.getSentCount()*80/topmsg:0%>%"></td>
            <td 
width="<%=topmsg!=0?100-(spd.getSentCount()*80/topmsg):0%>%">><%=spd.get
SentCount()%></td>
        </table>
    </td>
    </tr></table>
<%                 }
            }
%>


---------------------------------------------------------------------
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