my dog learned polymorphism*
The moose likes Struts and the fly likes New with Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "New with Struts" Watch "New with Struts" New topic
Author

New with Struts

Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
Hi all.
How do call an Action from another Action?
Thanks
Regards
Miguel
Nicola Guy
Ranch Hand

Joined: Jun 23, 2004
Posts: 91
You have to declare the actions in the struts-config.xml file that will call the other action once one is called
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
How do I declare it?
Nicola Guy
Ranch Hand

Joined: Jun 23, 2004
Posts: 91
Something like:

<action path="/register"
type="app.RegisterAction"
name="registerForm">
</action>

in the action-mapping section
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
But I'm not using a form
Nicola Guy
Ranch Hand

Joined: Jun 23, 2004
Posts: 91
you don't have to be.

wot are u doing?
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
I'm logging into an application. First I check all paremeter are OK and then I want to redirect to another Action that generates the main.jsp depending on the user
Nicola Guy
Ranch Hand

Joined: Jun 23, 2004
Posts: 91
I used:

<actionpath="/logon"
type="app.LogonAction"
name="LogonForm"
scope="request"
validate="true"
input="/index.jsp">
<forward name="success" path="/LogonSuccess.jsp"/>
<forward name="failure" path="/LogonFailure.jsp"/>
</action>

LogonForm was the name of my bean which holds the user info
app.LogonAction was the action i wanted to run the index.jsp was where the action was called from and the forward are the pages to open depending on what was returned from the action.

hope this help because i am still very new to struts and am having alot of problems myself.. i can't even get inot Tomcat!!!
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
Ok. Thanks a lot
Pankaj Narang
Ranch Hand

Joined: Jun 07, 2004
Posts: 81
hi miguel

I understood your application , you want to do a login module, for taht you simply need four things

1: Login.jsp
2:LoginForm.java
3:Loginaction.java
4:mian.jsp

the flow is that you put data in login.jsp, ou chaeck in validate method of loginform.java if correct you further go to loginaction and check the data with database forward it to main.jsp or back to login.jsp

This is simple then why you want to actions???

Best Regards
Pankaj
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
Great. I just need a new jsp!
Thanks
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
Now I have another problem.
The content in menu.jsp and body.jsp must be generated dynamically.

How do I do that?
How do I call an Action from there?
How does the Action returns the dynamic JSP?

Thanks a lot
Nicola Guy
Ranch Hand

Joined: Jun 23, 2004
Posts: 91
wot exactly are you looking to do?

wot details are you looking to display etc
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
I'm logging into a web application. I'm trying to load a menu bar and a body, and the content of both tiles must be dynamic, so I want to do it with an Action.
Nicola Guy
Ranch Hand

Joined: Jun 23, 2004
Posts: 91
Im still really new to this as well but if I understand wot you mean you can use

<logic resent> or <logic:notPresent>

to have certain items displayed or hidden
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
mmmm... I think that doesn't work...
thanks anyway
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: New with Struts
 
Similar Threads
Architect Certification Moderator MIA?
WA #1.....word association
some mighty fast rock climbing!
John Travolta's movies
good book for ajax