Thanks for replying Luc.

I tried changing the name of the bean (and removing the extra space) , and
JRun still blows up when it tries to compile.

Here's the new code in JSP:

<USEBEAN NAME="Customer" TYPE="bank.BankCustomer" LIFESPAN="page">
    <SETONCREATE BEANPROPERTY="Name" VALUE="John Smith">
</USEBEAN>

<LOOP PROPERTY="Customer:BankAccount" PROPERTYELEMENT="Account">
    <P>
        <DISPLAY PROPERTY="Customer:Name"><BR> <!-- This is the faulty line.
-->
        <DISPLAY PROPERTY="Account"><BR>
    </P>
</LOOP>



Here's the LOOP portion of Java created by JRun:

{
Object[] Account = JSP.getIndexedProps(Customer,"BankAccount");
for (int jsp_array_idx0=0;jsp_array_idx0<Account.length;jsp_array_idx0++) {
out.println("");
out.println("    <P>");
out.print("        ");

{
byte[] jsp_default0 = {110,117,108,108};
String res = JSP.beanVal(Customer[jsp_array_idx0],"Name", new
String(jsp_default0));
out.print(res);
}

{
byte[] jsp_default0 = {110,117,108,108};
String res = JSP.beanVal(Account[jsp_array_idx0],"", new
String(jsp_default0));
out.print(res);
}

out.println("<BR>");
out.println("    </P>");
}
}


The problem is that JRun is treating the Customer variable is an array.


QUESTION:  Does this only happen with JRun?  I'm including my files in case
someone wants to try it out.

 <<Accounts.jsp>>  <<BadAccounts.jsp>>  <<BankCustomer.java>>
Accounts.jsp uses <% %>, BadAccounts.jsp uses the DISPLAY tag (and doesn't
compile with JRun 2.3), and BankCustomer.java is the source for my Customer
bean.


Thanks,

Vaughn Wine



                -----Original Message-----
                From:   Vanlerberghe, Luc [mailto:[EMAIL PROTECTED]]
<mailto:[mailto:[EMAIL PROTECTED]]>
                Sent:   Wednesday, April 14, 1999 11:17 AM
                To:     [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
                Subject:        Re: Cannot access other bean properties in
LOOP

                It should work.  I can only think of two reasons why it
fails:
                - Maybe JRun 2.3's implementation gets confused because you
use the same
                name for your beans as for the name of their class.

                I know the sun reference implementation of 0.92 would create
code like:
                bank.BankCustomer

BankCustomer=(bank.BankCustomer)request.getAttribute("BankCustomer");
                if (BankCustomer==null) {
                // create a new bean, do the SETONCREATE stuff, etc.
                }

                While this code is valid, it's not so difficult to come up
with an example
                that wouldn't compile.  Perhaps sun should give some naming
guidelines for
                the beans too, like using at least one lowercase character
at the start like
                for normal variables.

                - Since <% BankCustomer.getName() %> DOES work, the above
doesn't apply, and
                the only thing that's left is the space in the property
parameter: <DISPLAY
                PROPERTY=" BankCustomer:Name">.
                JRun's parser probably searches for a bean with the name "
BankCustomer"
                instead of "BankCustomer"...

                Luc


                > -----Original Message-----
                > From: Wine Vaughn [mailto:[EMAIL PROTECTED]]
<mailto:[mailto:[EMAIL PROTECTED]]>
                > Sent: Wednesday, April 14, 1999 7:47 PM
                > To: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
                > Subject: Cannot access other bean properties in LOOP
                >
                >
                > PROBLEM:  I cannot access other bean properties in a LOOP.
                > In other words,
                > I can only access LOOP properties.
                >
                > EXAMPLE:  Say that I have a JSP aware bean called
                > BankCustomer, and the bean
                > has two properties: Name and an array type property called
                > BankAccount.  (My
                > bean, of course, has set/get methods for Name.  In
addition,
                > there is a
                > getBankAcountSize method that returns the size of the bank
                > account array,
                > and there is a getBankAccount method that takes an integer
as
                > an index into
                > the array.)
                >
                > The important part of my JSP page looks like this:
                >
                > <USEBEAN NAME="BankCustomer" TYPE="bank.BankCustomer "
                > LIFESPAN="page">
                >   <SETONCREATE BEANPROPERTY="Name"  VALUE="John Smith">
                > </USEBEAN>
                >
                > <LOOP PROPERTY="BankCustomer:BankAccount"
PROPERTYELEMENT="Account">
                >   Customer Name = <DISPLAY PROPERTY="
BankCustomer:Name"><BR>
                >   Bank Account = <DISPLAY PROPERTY="Account"><BR>
                >   <BR>
                > </LOOP>
                >
                > I want to produce output that lists all John's bank
accounts
                > (which are
                > retrieved from a database, let's say), but I what to
repeat
                > the customer
                > name each loop:
                >
                > John Smith
                > CHECKING1
                >
                > John Smith
                > SAVINGS1
                >
                > John Smith
                > SAVINGS2
                >
                >
                > However, this does not work!  It is choking on the
Customer
                > Name line in the
                > loop:  I'm using JRun 2.3 on NT 4.0 with IIS.  Is this a
                > problem with JRun
                > or a problem with the JSPs, in general?
                >
                >
                > The simple work around is to use <% %>:
                >
                > <LOOP PROPERTY="BankCustomer:BankAccount"
PROPERTYELEMENT="Account">
                >   Customer Name = <% BankCustomer.getName() %><BR>
                >   Bank Account = <DISPLAY PROPERTY="Account"><BR>
                >   <BR>
                > </LOOP>
                >
                >
                > What's so bad about this?  Well, I'm trying to put as much
                > functionality as
                > possible in the bean, so that I can avoid Java in the JSP.
                > Why?  So that I
                > can capitalize on the LOOP and DISPLAY tags and make the
JSP
                > appear like
                > HTML (to simplify the presentation elements of JSP).
                >
                >
                > GRIPE:  If Sun is going to add LOOP and DISPLAY tags, then
                > they should be
                > powerful enough to do something simple like this (what
I've
                > shown above).
                > If these new constructs are not powerful and flexible
enough,
                > then I think
                > they should be pulled completely.  I don't like mixing
these
                > tags with <%
                > %>.
                >
                > Your thoughts are welcome.
                >
                > Vaughn Wine
                >
                >
==============================================================
                > =============
                > To unsubscribe, send email to [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>  and
                > include in the body
                > of the message "signoff JSP-INTEREST".  For general help,
                > send email to
                > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>  and
include in the body of the message "help".
                >


===========================================================================
                To unsubscribe, send email to [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>  and include in the body
                of the message "signoff JSP-INTEREST".  For general help,
send email to
                [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>  and
include in the body of the message "help".

Accounts.jsp

BadAccounts.jsp

BankCustomer.java

Reply via email to