get action property
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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?
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?
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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?
<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
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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:
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
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
no, nothing helped
I have changed type, name of the property and there is still no output
login.jsp
CheckLoginAction.java
output:
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
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
misha nesterenko
Greenhorn
Posts: 28
Tom Rispoli
Ranch Hand
Posts: 349
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
nothing
what is attribute var in action tag for?
what is attribute var in action tag for?
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
try simple String type instead of boolean and see if something is displayed or not.
Have Fun with Java
little,little.. little by little makes a lot..
misha nesterenko
Greenhorn
Posts: 28
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
| Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |







