struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Husted <hus...@apache.org>
Subject Re: Struts action populate a list then display the jsp
Date Fri, 05 Oct 2001 09:36:40 GMT
Just tell the designer that all links must go through the Struts tags
(say, to maintain the session and relative path), and that the links
must use the logical forwards. If you provide a good list of the
forwards, and the forwards relate to something else from the design
phase (like a flow chart or a storyboard), they will actually find them
more convenient that hard paths, and will ~want~ to use them. You also
tell them that if they link directly to a JSP, the JSP will probably
fail because it won't have the right data. 

Then, you make sure that all the forwards goto Actions, and not JSPs. 

If you are really paranoid, run the occaisonal grep to see if there are
any <a tags or page= properties.

If your JSP does require data beans, it is not a bad idea to document
that with one or more logic present tags. In fact, an "expects" tags
that looked for several beans , and then branched to one place if any
were missing, sounds rather useful. JSP by contract sort of thing.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/about/struts/


Peter Pilgrim wrote:
> 
> Has there ever been a case where the action has accidently
> pushed out a real JSP and the user bookmarked that.
> 
> Ok lets take the struts example
> 
> In the EditRegistration action that forwards to "registration.jsp" you
> are saying, if the web app carefully, written no one should be able to pick
> up this jsp. Accept for a case when a web app developer or designer
> says I will include a hyperlink to "registration.jsp" directly.
> 
> I had another idea that was to have separate action divide and conquer
> approach. You could written the struts example to have a separate
> CreateRegistration and PromptRegistration actions. But I see your
> point. What should developer tell a designer ( I am doing both
> roles) ? Dont link directly to JSP within talking to me Developer?
> 
> What I would like is to have some form of failsafe
> 
> <logic:notPresent name="SUBSCRIPTION_LIST" >
> 
>      <%-- SOMETHING HERE --%>
> 
> </logic:notPresent>
> 
> I could redirect to the login screen, if the user is not logged in.
> I could redirect to the main index page, if the user is logged but
> accidently. I could redirect to some kind handy pandy error screen.
> I could even redirect to the action itself, but it could lead to endless
> recursion and the OutOfMemoryException.
> 
> I am thinking more along these lines, smells like custom tag again.
> But is it worth it, if Jonathon is absolutely correctly?
> 
> thoughts...
> 
> --
> Peter Pilgrim          |  |        ++44 (0)207-545-9923
>             .... \  \  ___   /  / ... .
>             -   ----  ( * )  ---   --
> _____________________________Cafe_Savannah,_San Antonio,Ibiza__
> 
> ---------------------------------------- Message History ----------------------------------------
> 
> From: "Jonathan M Crater" <jonathan_m_crater@fanniemae.com> on 01/10/2001 12:52
AST
> 
> Please respond to struts-user@jakarta.apache.org
> 
> To:   struts-user@jakarta.apache.org
> cc:
> Subject:  Re: Struts action populate a list then display the jsp
> 
> the idea is not to have your JSPs available for bookmarking.  if all your links point
to action mappings (e.g., *.do URIs) and you do forwards to all your JSPs, then a JSP will
never be visible in the URL pane of the user's browser.  that way, s/he can never bookmark
a JSP which could conceivably be displayed in an
> uninitialized state.
> 
> Peter Pilgrim wrote:
> 
> > Ah! but what if your action redirects to a view JSP, and then they book mark that?
> > Are we talking the same lingo here. What do you mean by link to action mappings
?
> > --
> > Peter Pilgrim          |  |        ++44 (0)207-545-9923
> >             .... \  \  ___   /  / ... .
> >             -   ----  ( * )  ---   --
> > _____________________________Cafe_Savannah,_San Antonio,Ibiza__
> >
> > ---------------------------------------- Message History ----------------------------------------
> >
> > From: Ted Husted <husted@apache.org> on 01/10/2001 12:20 AST
> >
> > Please respond to struts-user@jakarta.apache.org
> >
> > To:   struts-user@jakarta.apache.org
> > cc:
> > Subject:  Re: Struts action populate a list then display the jsp
> >
> > The best thing is to link only to ActionMappings and never to JSPs. Then
> > they can only bookmark the mapping. If anything is missing, it is much
> > easier to handle that from an Action than from a JSP.
> >
> > -- Ted Husted, Husted dot Com, Fairport NY USA.
> > -- Custom Software ~ Technical Services.
> > -- Tel +1 716 737-3463
> > -- http://www.husted.com/about/struts/
> >
> > Peter Pilgrim wrote:
> > >
> > > Chicken and the egg
> > >
> > > I have a data source and bean with a list of items
> > > One JSP view that list the content of the data source.
> > > I have one action.
> > >
> > > I want to allow the user to choose an element from the data source.
> > > My action populates the bean with the items, then go to the view.
> > > The problem is that the user bookmarks the view and of course
> > > there is no data in the bean. How do you populate the bean
> > > without going into the action first?
> > >
> > > What is the best practice of populating an a bean from the data
> > > source?
> > >
> > > Can you inside a JSP get a reference to an action or ask
> > > Struts to create it if it has not done it yet? If you can do
> > > that then you could call the action by pseudo action
> > > to populate the bean?
> > >
> > > Can you call an action without an action form?
> >
> > --
> >
> > This e-mail may contain confidential and/or privileged information. If you are not
the intended recipient (or have received this e-mail in error) please notify the sender immediately
and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material
in this e-mail is strictly forbidden.
> 
> --
> 
> This e-mail may contain confidential and/or privileged information. If you are not the
intended recipient (or have received this e-mail in error) please notify the sender immediately
and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material
in this e-mail is strictly forbidden.

Mime
View raw message