basic question about s:iterator
Sorry if this is too basic, but i seem to be missing something. The iterator tag documentation says it iterates over the value on top of the stack. I don't understand what this stack is and what is at the top of the stack. Can i use the iterator tag to iterate over an object stored as a session attribute? Any help much appreciated! -- View this message in context: http://www.nabble.com/basic-question-about-%3Cs%3Aiterator%3E-tp24141202p24141202.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: basic question about s:iterator
Perhaps the language is bad, but what I believe that documentation means is that when you are iterating the each object in the iteration is at the top of the stack so that when you do something like this: s:iterator value=#session.users s:property value=firstName/ /s:iterator Struts knows that you mean #session.users[i].firstName. It knows that based on how the value stack works. Here is a quote from an infoq.com article describing the Value Stack: http://www.infoq.com/articles/migrating-struts-2-part3 wrote: Instead of different scopes that the JSP developer needs to explicitly specify, Struts2 has a Value Stack. The Value Stack is just an order of different scopes that is traversed when looking for a value. When looking for a value, if a getter for the field is not found in one scope, the next scope is checked - this continues until either the field is found or all the scopes have been exhausted. The order of the scopes is: 1. Temporary Objects - these are objects that are created in the JSP page (we will see an example soon with the s:url tag), or they are objects created by tags that have short lives (such as the current object during a loop over a collection). 2. The Model Object - if model objects are being used, they are checked next (before the action). 3. The Action Object - this is the action that has just been executed. Hence, without explicitly placing the action in a session or request scope, you will still have access to its data. 4. Named Objects - these objects include #application, #session, #request, #attr and #parameters and refer to the corresponding servlet scopes. The advantage is clear - each scope, in turn, is checked for the field that you are after. However, if you have both a model object and action with the same field name (set's say id), then problems can occur. If you want the models value the correct result will be returned - but if you want the actions value, you will be returned the models value, as the model scope precedes the action scope. The solution is to provide a qualifier determining where in the stack you want to retrieve the id field - in this example [1].id would retrieve the value from the action. More information can be found online at http://cwiki.apache.org/WW/ognl-basics.html. So now you realize that instead of #session.users to get to your list you can just use users and it will search until it finds the users list in your session. jo_atman wrote: Sorry if this is too basic, but i seem to be missing something. The iterator tag documentation says it iterates over the value on top of the stack. I don't understand what this stack is and what is at the top of the stack. Can i use the iterator tag to iterate over an object stored as a session attribute? Any help much appreciated! -- View this message in context: http://www.nabble.com/basic-question-about-%3Cs%3Aiterator%3E-tp24141202p24141965.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: about s:iterator
Sove Error By s:iterator value=getDTlthis is for first elements:property value=top[1]/s:iterator Sébastien Domergue wrote: When you are inside an iterator, the context becomes the objet as it is in a for except that there is no explicit name for the property handled. In struts, it's a generic name : [0]. If you just want to display the toString() result, you just have to write : s:property/ without more parameter. If you want to print a special field of your bean, you can access it the same way as in the jsp with s:property value=.../ where [0] will be the current object in the iterator. If you want more examples, you should go [1] and see the third example. Regards [1] : http://struts.apache.org/2.x/docs/iterator.html Hardik Shah a écrit : Thnaks but when i print like s:property value=[0].{1}/ it shows value in all same like [1,1] i could not understand properly what it do please help more and be more descriptive Sébastien Domergue wrote: Hi, in an iterator, the object can be accessed by [0]. After that, it is as in Java. So, with something like that it should work : s:iterator value=getDTl s:prpoerty value=[0].{1}/ /s:iterator Regards Sébastien Hardik Shah a écrit : hi i am using struts 2.0.11.2 i m filling vector somthing like while (rs.next()) { Object [] record = { new Integer(rs.getInt(NodeId)), // Node Id rs.getString(NodeDisplayName), // Display Name new Integer(rs.getInt(ParentNodeId)), // Parent Id rs.getString(FolderName), // Folder Name rs.getString(CanReadFlag), // Can Read Flag rs.getString(CanAddFlag), // Can Add Flag rs.getString(CanEditFlag), // Can Edit Flag rs.getString(canDeleteFlag), // Can Delete Flag new Integer(rs.getInt(iformNo)), // No of comments rs.getString(Filename), //filename rs.getDate(ModifyOn), //file last modified on rs.getString(UserDefineVersionId) }; nodeInfo.addElement(record); how can i get particular field at jsp side in s:iterator somthing like that s:iterator value=getDTl s:prpoerty value={1}/ /s:iterator but i can not please help me - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- View this message in context: http://www.nabble.com/about-s%3Aiterator-tp22119987p22134055.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
about s:iterator
hi i am using struts 2.0.11.2 i m filling vector somthing like while (rs.next()) { Object [] record = { new Integer(rs.getInt(NodeId)), // Node Id rs.getString(NodeDisplayName), // Display Name new Integer(rs.getInt(ParentNodeId)), // Parent Id rs.getString(FolderName), // Folder Name rs.getString(CanReadFlag), // Can Read Flag rs.getString(CanAddFlag), // Can Add Flag rs.getString(CanEditFlag), // Can Edit Flag rs.getString(canDeleteFlag), // Can Delete Flag new Integer(rs.getInt(iformNo)), // No of comments rs.getString(Filename), //filename rs.getDate(ModifyOn), //file last modified on rs.getString(UserDefineVersionId) }; nodeInfo.addElement(record); how can i get particular field at jsp side in s:iterator somthing like that s:iterator value=getDTl s:prpoerty value={1}/ /s:iterator but i can not please help me -- View this message in context: http://www.nabble.com/about-s%3Aiterator-tp22119987p22119987.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: about s:iterator
Hi, in an iterator, the object can be accessed by [0]. After that, it is as in Java. So, with something like that it should work : s:iterator value=getDTl s:prpoerty value=[0].{1}/ /s:iterator Regards Sébastien Hardik Shah a écrit : hi i am using struts 2.0.11.2 i m filling vector somthing like while (rs.next()) { Object [] record = { new Integer(rs.getInt(NodeId)), // Node Id rs.getString(NodeDisplayName), // Display Name new Integer(rs.getInt(ParentNodeId)), // Parent Id rs.getString(FolderName), // Folder Name rs.getString(CanReadFlag), // Can Read Flag rs.getString(CanAddFlag), // Can Add Flag rs.getString(CanEditFlag), // Can Edit Flag rs.getString(canDeleteFlag), // Can Delete Flag new Integer(rs.getInt(iformNo)), // No of comments rs.getString(Filename), //filename rs.getDate(ModifyOn), //file last modified on rs.getString(UserDefineVersionId) }; nodeInfo.addElement(record); how can i get particular field at jsp side in s:iterator somthing like that s:iterator value=getDTl s:prpoerty value={1}/ /s:iterator but i can not please help me - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: about s:iterator
Thnaks but when i print like s:property value=[0].{1}/ it shows value in all same like [1,1] i could not understand properly what it do please help more and be more descriptive Sébastien Domergue wrote: Hi, in an iterator, the object can be accessed by [0]. After that, it is as in Java. So, with something like that it should work : s:iterator value=getDTl s:prpoerty value=[0].{1}/ /s:iterator Regards Sébastien Hardik Shah a écrit : hi i am using struts 2.0.11.2 i m filling vector somthing like while (rs.next()) { Object [] record = { new Integer(rs.getInt(NodeId)), // Node Id rs.getString(NodeDisplayName), // Display Name new Integer(rs.getInt(ParentNodeId)), // Parent Id rs.getString(FolderName), // Folder Name rs.getString(CanReadFlag), // Can Read Flag rs.getString(CanAddFlag), // Can Add Flag rs.getString(CanEditFlag), // Can Edit Flag rs.getString(canDeleteFlag), // Can Delete Flag new Integer(rs.getInt(iformNo)), // No of comments rs.getString(Filename), //filename rs.getDate(ModifyOn), //file last modified on rs.getString(UserDefineVersionId) }; nodeInfo.addElement(record); how can i get particular field at jsp side in s:iterator somthing like that s:iterator value=getDTl s:prpoerty value={1}/ /s:iterator but i can not please help me - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- View this message in context: http://www.nabble.com/about-s%3Aiterator-tp22119987p22120181.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: about s:iterator
When you are inside an iterator, the context becomes the objet as it is in a for except that there is no explicit name for the property handled. In struts, it's a generic name : [0]. If you just want to display the toString() result, you just have to write : s:property/ without more parameter. If you want to print a special field of your bean, you can access it the same way as in the jsp with s:property value=.../ where [0] will be the current object in the iterator. If you want more examples, you should go [1] and see the third example. Regards [1] : http://struts.apache.org/2.x/docs/iterator.html Hardik Shah a écrit : Thnaks but when i print like s:property value=[0].{1}/ it shows value in all same like [1,1] i could not understand properly what it do please help more and be more descriptive Sébastien Domergue wrote: Hi, in an iterator, the object can be accessed by [0]. After that, it is as in Java. So, with something like that it should work : s:iterator value=getDTl s:prpoerty value=[0].{1}/ /s:iterator Regards Sébastien Hardik Shah a écrit : hi i am using struts 2.0.11.2 i m filling vector somthing like while (rs.next()) { Object [] record = { new Integer(rs.getInt(NodeId)), // Node Id rs.getString(NodeDisplayName), // Display Name new Integer(rs.getInt(ParentNodeId)), // Parent Id rs.getString(FolderName), // Folder Name rs.getString(CanReadFlag), // Can Read Flag rs.getString(CanAddFlag), // Can Add Flag rs.getString(CanEditFlag), // Can Edit Flag rs.getString(canDeleteFlag), // Can Delete Flag new Integer(rs.getInt(iformNo)), // No of comments rs.getString(Filename), //filename rs.getDate(ModifyOn), //file last modified on rs.getString(UserDefineVersionId) }; nodeInfo.addElement(record); how can i get particular field at jsp side in s:iterator somthing like that s:iterator value=getDTl s:prpoerty value={1}/ /s:iterator but i can not please help me - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: about s:iterator
Hardik Shah wrote: while (rs.next()) { Object [] record = { new Integer(rs.getInt(NodeId)), // Node Id rs.getString(NodeDisplayName), // Display Name new Integer(rs.getInt(ParentNodeId)), // Parent Id tabsrs.getString(FolderName), // Folder Name are rs.getString(CanReadFlag), // Can Read Flag evilrs.getString(CanAddFlag), // Can Add Flag rs.getString(CanEditFlag), // Can Edit Flag rs.getString(canDeleteFlag), // Can Delete Flag new Integer(rs.getInt(iformNo)), // No of comments rs.getString(Filename), //filename rs.getDate(ModifyOn), //file last modified on rs.getString(UserDefineVersionId) }; nodeInfo.addElement(record); how can i get particular field at jsp side in s:iterator s:iterator value=getDTl s:prpoerty value={1}/ /s:iterator Maybe try [0][n]? But yuck... That's a horribly brittle way to write code. At *least* use a map so you don't have to rely on positioning :/ Consider using an actual object, as well, thus eliminating the bulk of this question. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: about s:iterator
yap you right newton.dave wrote: Maybe try [0][n]? But yuck... That's a horribly brittle way to write code. At *least* use a map so you don't have to rely on positioning :/ Consider using an actual object, as well, thus eliminating the bulk of this question. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- View this message in context: http://www.nabble.com/about-s%3Aiterator-tp22119987p22132774.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org