• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

get action property

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

I have login.jsp


checkLogin action is mapped to CheckLoginAction.java


how can I get isLoggedIn property in <s:property...> after executing action checkLogin in login.jsp?
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have you tried:

<s:property value="isLoggedIn"/>

This works for me, however, instead of a getter method I would use a method named isIsLoggedIn (might want to change the variable name if you do that though). I would think the getter method would work but maybe struts2 can't convert the boolean to a string if you do that. If that doesn't work, can you indicate what is going wrong with it?
 
misha nesterenko
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have added getter method isIsLoggedIn, so CheckLoginAction.java now looks like:


and I get the property like:
<s:property value="isLoggedIn"/>

It shows just nothing
excerpt from top of login.jsp:


and how it is rendered to html:
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I played around with this a little. I think the problem is you are using Boolean, and I am using boolean. I guess the s:property can't handle that wrapper class around the boolean (although I admit that seems wierd since it does have a toString method). I recommend trying to use the native type boolean instead of Boolean and see if that fixes your problem.
 
misha nesterenko
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no, nothing helped

I have changed type, name of the property and there is still no output

login.jsp


CheckLoginAction.java


output:
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Strange, this code looks like it should access the values in your action class. Are you sure your action class is being called? Are you calling the JSP directly?
 
misha nesterenko
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I directly call jsp file, action is definetly called (I added Syste.out.println("sdfsdfsdf") in the execute method and I can see in the tomcat console sdfsdfsdf printed when I call login.jsp)
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this in your jsp:

 
misha nesterenko
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
doesnt work
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm at a loss. The next thing I would try would be to put an s:debug tag between the <s:action> and </s:action> tags to see what's on the stack. Maybe that will clear up why loggedIn isn't accessible.
 
misha nesterenko
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nothing



what is attribute var in action tag for?
 
Ranch Hand
Posts: 329
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Novice in struts2 but just want to check what is happening,
try simple String type instead of boolean and see if something is displayed or not.
 
misha nesterenko
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and, one more question, we can access properties via their name only if they belong to a current action (which is stored in top of the ValueStack), so how can I tell where to look for this property?
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmm... looking at the api for the action tag, it looks like I misunderstood how it works. I think you'll want to set the executeResult attribute of it to true, then in your struts.xml file specify a JSP for it to use to generate its output, then in that JSP you should be able to access loggedIn with OGNL. I also thought you could use that tag to do what you are trying to do, but It looks like I'm mistaken.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic