2010/5/14 Martin Gainty <mgai...@hotmail.com>

>
>
> > Date: Fri, 14 May 2010 19:10:20 +0200
> > Subject: More action in one view
> > From: perfabi...@gmail.com
> > To: user@struts.apache.org
> >
> > Hi all, i am a newbie of struts. Before to start i want to say sorry for
> my
> > bad english. I looked for any forum/blogs in my language (italian) :(
> > I am developing a project for a university course.
> >
> > the first page is a login form, if the login success i have to show the
> > index of a nurse or a doctor. It depends from the account.
> > For do this i used a interceptor and all work...
>
>
>
> mg>Which Interceptor are you referring to?
>

I have written an interceptor (the doc help me) that check if there is a
"dipendente" (employee) in the session.

public class AuthInterceptor  implements Interceptor {

public void destroy() {
}

public void init() {
}

public String intercept( ActionInvocation actionInvocation ) throws
Exception {
System.out.println("SONO NELL'INTERCETTORE");
 Map session = actionInvocation.getInvocationContext().getSession();
purgeStaleTokens(session);
 Dipendente dipendente = (Dipendente) session.get( "dipendente" );
if (dipendente == null) {
    return Action.LOGIN;
}
else {
    Action action = ( Action ) actionInvocation.getAction();

    if (action instanceof DipendenteAware) {
        ((DipendenteAware)action).setDipendente(dipendente);
    }

    System.out.println("Logged in: interceptor");
    return actionInvocation.invoke();

}

}

>
>
> >
> > Now i want that every page show the information about the worker, for
> > example the name, the surname and the id.
> > At the same time i want to do other action for example search patient,
> > insert new, open a new medical record about a patient ... but any page
> must
> > show the information of the nurse!
> >
> > How can i do? The principal problem is choose the action class.
>
> mg>every action has input (form) and n results (usually success result jsp
> page/failure result jsp pages)
>
>
ok, I know!
i want that,for example, there are the name and surname of who is logged.

My AuthInterceptor check if a "dipendente" is in the session and if true,
put (with setDipendente(dipendente)) the user in the action.
So in the action i have to override the setDipendente(Dipendente dipendente)
and implement getDipendente() for show in the view the dipendente name and
surname:

<h1>nurse</h1>
<div class="info">
<h3>your info</h3>
<p>Name: <s:property value="dipendente.nome" /><br />
surname: <s:property value="dipendente.cognome" /><br />
Username: <s:property value="dipendente.username" /><br />
</p>
<h6><a href="<s:url action='doLogout'/>">Logout</a></h6>
</div>

I want that this info will be show in every secure page (so after the
login).

Now how can i do that? i think that isn't correct put in every action the
variable Dipendente dipendente, implements DipendenteAware, override
setDipendente and implement getDipendente!!! I repeat the same code in every
action!!!!

I think to write an action for example DipendenteInfo that have the variable
dipendente, with setter and getter, and after extend this class with other
class that needs to show the info.
But i am not sure...

>
> > Thanks
> > Fabio Perfetti
>
>
>
> mg>way too little information to provide a comprehensive answer without
> looking at
> mg>a complete listing of current dbschema
>
> mg>a complete display of all action classes you current are implementing
>
> mg>applicationContext.xml
> mg>web.xml
> mg>/WEB-INF/classes/struts.xml
>
> mg>WEB-INF/classes/globalMessages.properties
> mg>jsp pages
>
>
>
> mg>also include any *validation.xml you might be implementing
>

I am using the hibernate plugin and i use the validation with @NotEmpty
etc...


>
> mg>are you using ORM like hibernate/toplink or are you going
> querying/inserting/updating with jdbc?
>

yes, i am using hibernate!


>
>
> mg>why dont you track down this italian professor that is getting paid to
> (supposedly) help you
>

good idea..but now i have to try and "train by myself" (now understand why
the english people speak an horrible italian)
thanks for the patience :D
Fabio

>
> _________________________________________________________________
> The New Busy is not the too busy. Combine all your e-mail accounts with
> Hotmail.
>
> http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4
>

Reply via email to