Using MOD function in <logic:equal> tag

T

TheVooDooChild

I'm working with a table that needs to be built dynamically based on
whether or not I need to use certain controls. What I need are table
rows of 3 columns each, displaying at most 10 fields (3 rows of 3, 1
row of 1). The problem is that I don't always need all 10 fields, I
could only need 6 (2 rows of 3) for example. So, I need to know when
to end a row and start a new row.

What i'm trying to do is something like this:
<bean:define id="numCol" value="0" />
then I need a check using the MOD function to see if I need to end a
row and start a new one:
<logic:equal name="numCol" value="0" property="<%=3%numColumns%>">
</tr>
<tr>
</logic:equal>

Currently, I have the error "Error(139,73): method %(int,
java.lang.String) not found in class _pages._customerHoldingVerifyJSP

Can anyone help please?
Thank you
 
T

TheVooDooChild

The hell with Struts tags! I give up, I'm using scriptlets!

<% int numColumns = 0; %>
...
<% numColumns++; %>
...
<% if ( numColumns % 3 == 0 ) { %> </tr><tr> <% } %>

So much easier!
 
O

Oscar kind

TheVooDooChild said:
I'm working with a table that needs to be built dynamically based on
whether or not I need to use certain controls. What I need are table
rows of 3 columns each, displaying at most 10 fields (3 rows of 3, 1
row of 1). The problem is that I don't always need all 10 fields, I
could only need 6 (2 rows of 3) for example. So, I need to know when
to end a row and start a new row.

What i'm trying to do is something like this:
<bean:define id="numCol" value="0" />
then I need a check using the MOD function to see if I need to end a
row and start a new one:
<logic:equal name="numCol" value="0" property="<%=3%numColumns%>">
</tr>
<tr>
</logic:equal>

Currently, I have the error "Error(139,73): method %(int,
java.lang.String) not found in class _pages._customerHoldingVerifyJSP

The result of 3%numColumns is not the name of a property (with a get...()
method). Despite the fact that it's possible to define (for example) a
method get2(), I don't think this is what you mean.

Besides that, you are defining a bean "numCol" to be "0", and then try to
get a property from that. However, neither the value 0 nor the String "0"
are beans.

In your other post, I see you want to compare numCols with the
expression 3%numColumns (assuming you don't mean numColumns%3). If that is
so, why not omit the property attribute? It is not required:

<logic:equal name="numCol" value="<%=3%numColumns%>">
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top