• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • 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




 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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:



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic