Hello Darren,

I can understand why it does not work, because there is no defined sequence
of priority.
One way which _will_ work would be...

        <USEBEAN name="sol_bean" type="jsp.speakoutloud.SpeakOutLoudBean"
        lifespan="page">
        </USEBEAN>

        <%
                //Put decision logic here...
                if(world_is_at_an_end){
                        //set the bean state to output contents in a
particular way

sol_bean.setRequiredOutputProperty(some_identifying_value)
                }else{
                        //set the bean state to output contents in a
particular way

sol_bean.setRequiredOutputProperty(some_other_identifying_value)
                }
        %>

        <LOOP property="genericPropertySet" propertyelement="x">
                <DISPLAY property="x">
        </LOOP>

The "setRequiredOutputProperty" property would control the following
internal bean code

public InterfaceWithX[] getGenericPropertySet(){
        switch (some_identifying_value){
                case siv1:
                        return getSpecificPropertySet1();
                case siv2:
                        return getSpecificPropertySet2();
        ....}

}

In other words...
Get the return value from the bean through a generic interface and set the
particular return values via another property.
This will also allow easier compile-time type checking.

Note: It would be better if you could use INCLUDEIF and the like to decide
on SETONCREATE tags while instantiating the bean.  Again, the mixing may
confuse the JSP engine.  I wonder if the 1.0 spec will include SET tags for
downstream bean attribute setting?

I hope this helps.

Miles Chaston
E-mail: [EMAIL PROTECTED]

> -----Original Message-----
> From: Darren Ehlers [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, April 16, 1999 7:27 PM
> To:   [EMAIL PROTECTED]
> Subject:      Using <LOOP...> and <% ... %> Possible in same statement?
>
> I'm trying to get the following line of code to work:
> <LOOP property="<% out.print( "sol_bean:" + sProperty ); %>"
> propertyelement="x">
>
> I want to use a different property of the bean depending on a parameter
> passed to the .jsp file
>
> My guess is that it is trying to evaluate <LOOP before evaluating the <%
> script.  It seems to me though that it should evaluate the in-line scripts
> prior to evaluating the html tags.
>
> See complete code below (the rest of the statements work fine).
>
> I'm using NT 4(SP4)/NES 3.6/JRun 2.3
>
> Thanks for any help,
> Darren
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> <USEBEAN name="sol_bean" type="jsp.speakoutloud.SpeakOutLoudBean"
> lifespan="page">
> </USEBEAN>
>
> <%
> String sType = request.getParameter("type");
> String sDisplay = "";
> String sProperty = "";
> if (sType.equals("ind")) {
>  sDisplay = "Industry";
>  sProperty = "markets";
>
> } else if (sType.equals("comp")) {
>  sDisplay = "Company";
>  sProperty = "companies";
>
> }
>  %>
>
> <font face="tahoma" size="-1"><b>Select <% out.print( sDisplay ); %> to
> Delete</b></font>
> <p>
>
> <form method="post" action="<% out.print( "/servlet/sol_servlet?type=" +
> sType ); %>" name="form">
> <select multiple name="lstIndustries" size="20">
> <LOOP property="<% out.print( "sol_bean:" + sProperty ); %>"
> propertyelement="x">
> <option><DISPLAY property="x">
> </LOOP>
> </select>
>
> ==========================================================================
> =
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff JSP-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
The information transmitted is intended only for the person or entity to which it is 
addressed and may contain confidential and/or privileged material.  Any review, 
retransmission, dissemination or other use of, or taking of any action in reliance 
upon, this information by persons or entities other than the intended recipient is 
prohibited.   If you received this in error, please contact the sender and delete the 
material from any computer.

PricewaterhouseCoopers Kinesis Ltd

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

Reply via email to