• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

[solved] passing 3 times by default through action using struts 2

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Data action gets called 3 times. I searched my code i haven't found anything that would do that.
Furthermore i didn't find anything that would run getData() from my Data.java action class, but i can use the data it makes in data.jsp.
I have to paste the code, seems it doesn't allow archives. The code passes 3 times where i used the line: System.out.println("setting query");
data.jsp

Data.java




 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this question missing something?? You've shown a JSP page, but what's the name of that jsp page?? Is it data.jsp, how is it concerned with action getting called three times?? How are you actually reaching to Data action?? Are you making a URL request by typing the URL in the browser's address bar??
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
data.jsp (above) gets called from main which gets called from dataParams.jsp, main and dataParams action only return success:
dataParams.jsp


main.jsp


struts.xml
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I debugged the application and it does this weird thing:
it runs fine until it gets to data.jsp, then, after parsing this it jumps back to action:

on this line:



then it jumps back after a while at the line it jumped out of and parses until it jumps back to action upon finishing the loop, then comes back from the jump to this line:

after this it exits normally. Why is this happening, and how does Data.java know to run getData()?
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for triple posting, but i'm working a timeline here
I think i got it myself. Seems that getData() is beeing called by something else (very weird) because when i renamed it to getSomeStuff(),
it doesn't run at all no more. Good ol' debugging.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because you keep calling ${data.xxx} in the JSP, which means it's going to call getData() on the action each time.

I'd consider spending some time with the S2 documentation, since this kind of stuff is very basic to the framework.

It's not weird at all--you just don't know how the framework works.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for promptness. I thought that it's bound to the action class as a bean too, thus data.property, but it was working because it was seeing getData as a property so I see how that works, you were saying Action sets the property to the action context...
Solved like:



reply
    Bookmark Topic Watch Topic
  • New Topic