Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7089821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:58:08+00:00 2026-05-28T07:58:08+00:00

I am new to strut 2 though I have worked on struts 1.2.In one

  • 0

I am new to strut 2 though I have worked on struts 1.2.In one of the pexisting project jsp file I have following code:

<script type="text/javascript">
  var relationshipData = { // line1
    page : '<s:property value="displayPage" />', // line2
    records : '<s:property value="customerRelations.size" />', // line3
    rows : [ <s:iterator value="customerRelations" status="iterStatus"> // line4
      { id : '<s:property value="relationId" />', 
        cell : [ '<s:property value="relationDesc" escapeJavaScript="true" />' ] } <s:if test="!#iterStatus.last">,</s:if> //line5
        </s:iterator>] // line6
  };
</script>

Request is coming CustomerRelationAction.java which has method getCustomerRelations() and getRelationId().

here are the questions :-

  1. I put breakpoint inside method getCustomerRelations().i see flow is coming four time inside this method. Two times at line 3 and another two times at line 4.
    As per my understanding flow should come only 1 time i.e at line 3. Once it completes getCustomerRelations at line 3 , should not put its value in value stack so that
    it can refer to it nextime it is refered (like it is being reffered at line 14 again)?

  2. getCustomerRelations() method returns the list of CustomerRelationData objects where CustomerRelationData class also contains the getRelationId() method.Now at line
    5 we are refering value=”relationId at line 5. On Which object(CustomerRelationAction.java or CustomerRelationData), getRelationId() method will be called?
    even i am not sure will the list object CustomerRelationData will be present on value stack or not?If yes at which line it will be put in value stack?

  3. Now the iterator completes at line 6.After that,now i refer the code <s:property value="relationId" /> again, On Which object(CustomerRelationAction.java or CustomerRelationData),
    getRelationId() method will be called?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:58:09+00:00Added an answer on May 28, 2026 at 7:58 am

    1) I don’t know why you think calling for a property of customerRelations and then using customerRelations in an iterator tag would only call getCustomerRelations() once; you’re using it twice, so at a minimum it’ll get called twice.

    If you want to keep a reference to it, use <s:set> to create a new reference to the collection. I don’t see a point to doing so, however, unless your getter is doing something time-consuming.

    I don’t see the same behavior. Given the question’s <script> snippet, it renders thusly (assuming a dummy, three-element list with sample data):

    <script type="text/javascript">
      var relationshipData = { // line1
        records : '3', // line3
        rows : [  // line4
          { id : '1',
            cell : [ 'desc 1' ] } , //line5
           // line4
          { id : '2',
            cell : [ 'desc 2' ] } , //line5
           // line4
          { id : '3',
            cell : [ 'desc 3' ] }  //line5
          ] // line6
      };
    </script>
    

    And the log output, with a debug statement in the getter, is this:

    2012-01-19 13:58:10,552 DEBUG [TextExampleAction.java:18] : Enter.
    2012-01-19 13:58:10,571 DEBUG [TextExampleAction.java:18] : Enter.
    

    I’m more likely to believe the JSP/JS/etc. at this point.

    2) The iterator tag puts each object on the top of the stack, as described in the tag docs. The top of the stack is the first object that will be used to get the value of relationId. If it isn’t found on the stack top, OGNL will traverse the value stack until either the property is found, or there’s no more stack.

    3) See the previous answer: once you’re out of the iterator, there’s no longer a customer relation on the stack, and you’re back to the action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to start a new struts 2 project using maven (struts2 blank archetype)
I have the following (crude) function, which continually watches a directory for new files
I am new to C programming, and have a question about the following couple
I currently have the following code. struct qnode { char *path; struct qnode *next;
I am new to struts 2.I am designing a page in struts 2.I want
I am new to struts. I want to load a list of data in
I am new to struts 2. I am facing problem in filling Select tag
I am new to Struts . I downloaded Struts2 from its website. Now I
I am relatively new to C++ and am having problems understanding struct. I have
Having code: struct B { int* a; B(int value):a(new int(value)) { } B():a(nullptr){} B(const

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.