#application['foo'] or #application.foo ServletContext attributes 'foo' 
#attr['foo'] or #attr.foo Access to PageContext if available, otherwise 
searches request/session/application respectively

If I have stored the ArrayList in the ServletContext, Why it only works with 
attr?

I am confused.
  ----- Original Message ----- 
  From: dusty [via AppFuse] 
  To: Juan Antonio 
  Sent: Wednesday, May 19, 2010 7:21 AM
  Subject: Re: Populate a select with a list from servletcontext


  Try #attr.types 

  When you say sometimes, do you mean each time you load the page it works 
sometimes and if you reload sometimes it works, or it never works? 

  Also, an ArrayList is a container so you don't need to initialize its size.  
I don't think you are using the capacity parameter in the constructor the way 
you think you are.  Just types = new ArrayList() works fine.   

  -D 
  On May 18, 2010, at 8:57 PM, Juan Antonio wrote: 


  > 
  > Hello again: 
  > 
  > I have a jsp code like this: 
  > 
  > 
  > <div> 
  >   <s:select name="type" list="#application.types" label="Tipo contenido:" 
  > /> 
  > <div> 
  > 
  > 
  > Where I populate a select from the a ServletContext attribute: 
  > 
  > 
  > public class UserDataListener implements HttpSessionAttributeListener, 
  > ServletContextListener  { 
  > 
  >        ... 
  > 
  > public void contextInitialized(ServletContextEvent sce) { 
  > 
  > ServletContext servletContext = sce.getServletContext();   
  >                types = new ArrayList(3); 
  > types.add(Constants.UNO); 
  > types.add(Constants.DOS); 
  > types.add(Constants.TRES); 
  > servletContext.setAttribute("types", types); 
  > 
  >       } 
  > 
  >      ... 
  > } 
  > 
  > 
  > 
  > Sometimes, I found a message like "Caught an exception while evaluating 
  > expression '#application.types": java.lang.NullPointException" 
  > 
  > I don't know what i am doing wrong (i copied the code from a struts 2 
manual 
  > :confused: ) 
  > 
  > Any clue? 
  > 
  > I also tried #application['types'], and still nothing. 
  > 
  > Thanks. 
  > -- 
  > View this message in context: 
http://appfuse.547863.n4.nabble.com/Populate-a-select-with-a-list-from-servletcontext-tp2222242p2222242.html
  > Sent from the AppFuse - User mailing list archive at Nabble.com. 
  > 
  > --------------------------------------------------------------------- 
  > To unsubscribe, e-mail: [hidden email] 
  > For additional commands, e-mail: [hidden email] 
  > 


  --------------------------------------------------------------------- 
  To unsubscribe, e-mail: [hidden email] 
  For additional commands, e-mail: [hidden email] 




------------------------------------------------------------------------------

  View message @ 
http://appfuse.547863.n4.nabble.com/Populate-a-select-with-a-list-from-servletcontext-tp2222242p2222289.html
 
  To unsubscribe from Populate a select with a list from servletcontext, click 
here. 


-- 
View this message in context: 
http://appfuse.547863.n4.nabble.com/Populate-a-select-with-a-list-from-servletcontext-tp2222242p2222671.html
Sent from the AppFuse - User mailing list archive at Nabble.com.

Reply via email to