struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ray Madigan" <...@madigans.org>
Subject RE: Newbie Question
Date Tue, 11 Feb 2003 08:07:07 GMT
Thanks for the advice - i didn't know this stuff existed.

I was just pondering how to implement logic like
if ! A || ( A && B )

And had trouble seeing how to write some reasonable code

Thanks

-----Original Message-----
From: Jacob Hookom [mailto:hookomjj@uwec.edu]
Sent: Monday, February 10, 2003 11:50 PM
To: 'Struts Users Mailing List'
Subject: RE: Newbie Question


This is illegal (you can't embed tags as attributes):

<logic:equal name="component" property="name" scope="page"
               value="<bean:write name="navigateForm"
property="component"/>">

If you must use logic such as this, do yourself a favor and switch to JSTL
:-)

<c:forEach var="component" items="${components}">
    <c:if test="${component.name == navigateForm.component}">
        <tr>
            <td colspan="2" align="left">
               <c:out value="${component.name}" /></td>
        </tr>
    </c:if>
</c:forEach>

http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html

I can't say enough about JSTL.  With Struts and JSTL, the only Struts tags
you should ever use are the html:form tags and possibly bean:message.

-Jacob


| -----Original Message-----
| From: Ray Madigan [mailto:ray@madigans.org]
| Sent: Tuesday, February 11, 2003 1:23 AM
| To: Struts Users Mailing List
| Subject: RE: Newbie Question
|
| Here is my new code:
|
| ArrayList components = ( ArrayList ) service.gatherAccessory
|  Bean.getContainer ( ) );
| request.setAttribute ( "components", components );
|
| the jsp:
| <logic:iterate id="component" name="components" scope="request" >
|   <logic:equal name="component" property="name" scope="page"
|                value="<bean:write name="navigateForm"
| property="component"/>">
|     <tr>
|       <td COLSPAN="2"align="left">
|         <bean:write name="component" property="name" filter="false"/>
|       </td>
|     </tr>
|   </logic:equal>
| </logic:iterate>
|
| I get the ServletException:
| Cannot find bean container in any scope
|
| If I remove the <tr><td><bean:write: .../></td></tr>
| It is fine -doesn't fault - doesn't write anything
|
| If I remove the <logic:equal ...></logic:equal>
| It will iterate the list only once.
| I have print statements in the Action
|
| Im stumped? Any Ideas
|
| I will try Struts 1.0.2 - Except the examples seem to work :-)
|
| Thanks for your help
| Ray Madigan
|
| -----Original Message-----
| From: Jacob Hookom [mailto:hookomjj@uwec.edu]
| Sent: Monday, February 10, 2003 10:24 PM
| To: 'Struts Users Mailing List'
| Subject: RE: Newbie Question
|
|
| ArrayList components = (ArrayList) service
|
| .gatherAccessory(Bean.getContainer());
|
| session.setAttribute("someKey", components);
|
| -or-
| request.setAttribute("someKey", components);
|
|
| <!-- jsp -->
|
| <logic:iterate id="item" name="someKey" scope="session"> //or request
| scope
|   <bean:write name="item" property="name" /><br />
| </logic:iterate>
|
| -Jacob
|
| | -----Original Message-----
| | From: Ray Madigan [mailto:ray@madigans.org]
| | Sent: Tuesday, February 11, 2003 12:06 AM
| | To: Struts Users Mailing List
| | Subject: Newbie Question
| |
| | Greetings:
| |
| | I am new to struts, and i have a question that has been giving me fits
| all
| | day.
| |
| | I have a large application I am attempting to rewrite in struts, with
| | several hundred jsp's and servlets.  It currently runs on Tomcat.  I am
| | using, don't all of you laugh at once, 1.1-b3.
| |
| | I haveured out some of how struts works from reading the samples and
| | groping
| | throught the code, but i can't seem to figure out how to make
| | logic:iterate
| | work.  Here are a couple oc code fragments, if someone could point out
| | where
| | i'm a bonehead, i would appreciate it.
| |
| | In the Action class:
| |     ArrayList components = ( ArrayList ) service.gatherAccessory
| |  Bean.getContainer ( ) );
| |     // Error checking and logging etc
| |     if ( components != null && components.size ( ) > 0 ) {
| |         System.out.println ( "Nav: Comp: " + components.size ( ) );
| |         //txSupport component = new txSupport ( );
| |         //session.setAttribute ( Constants.COMPONENT_KEY, components.get
| | ( 1 ) );
| |         //session.setAttribute ( Constants.COMPONENTS_KEY,
| | components.toArray ( as ) );
| |         session.setAttribute ( component, components.get ( 0 ) );
| |         navForm.setComponents ( components );
| |     }
| |
| | I have tried several alternatives as to how to set the id attribute:
| | - an empty instance of the Bean that is contained in the collection
| | - the first element in the array
| | I have tried to set the name property of the iterate to an array
| | all with different errors.  The one that worked the best was when
| | I pointed the id property of iterate to the first element of the
| | Collection.  Here i simply got the iterator to iterate the first
| | element.  In the Action class I have iterated the Collection and
| | there are three elements in the list.
| |
| | In the jsp:
| |
| |   <logic:iterate id="component" name="navigateForm"
| property="components"
| | >
| |
| |     <tr>
| |       <td COLSPAN="2"align="left">
| |         <bean:write name="component" property="support" filter="true"/>
| |       </td>
| |     </tr>
| |
| |   </logic:iterate>
| |
| | The navigateForm has a pair of methods get/setComponents that return the
| | Collection.  If I put a logic:equal and test a member of the iteration
| it
| | works in all cases.
| |
| | I am very perplexed by this situation and any light shed on the problem
| | would be appreciated.
| |
| | Thanks in advance
| | Ray Madigan
| |
| |
| | ---------------------------------------------------------------------
| | 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
|
|
| ---------------------------------------------------------------------
| 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


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


Mime
View raw message