RE: Dynamic Form Beans?

2001-08-29 Thread John Townsend

The one idea that I had was to create a new subclass of ActionForm
called ActionDataForm. This form would have get and put methods that use
keys instead of the usual pattern of numerous getters/setters. 
 

For the process of saving form data, we could add a new override to
RequestUtils.processPopulate(..) which would take an ActionDataForm
instead of an ActionForm as its form instance. Then we would implement
this method to use get and put with keys instead of getters/setters.

One problem: I don't know how the populate works from the other side
(meaning when you want to prepopulate a form based on the contents of a
JavaBean in the session, etc.). I imagine that logic is contained in the
HTML tag libraries or some other tag library.

I guess what I am wondering is that since a number of people have run
into this and needed a solution I assumed that there might already be a
solution to this problem. If not, maybe we can find a solution and then
submit a patch to Struts for 1.1 or something.

Anyone else have any thoughts on this?

-- John Townsend

PS. One thing I just thought of: I wonder if there is a JavaBeans
solution to this problem? If there is, that might be a better way to go.


-Original Message-
From: Luis Olivares [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, August 29, 2001 11:28 AM
To: [EMAIL PROTECTED]
Subject: Re: Dynamic Form Beans?

I have the same 'problem'.

I would like to be able to create a form dynamically depending on the
structure of a table (I used to do this with 'plain' JSP).
Any ideas?

Regards.
   Luis Olivares.
   [EMAIL PROTECTED]
   --
  Intelligence is the ability to avoid doing
   work, yet getting the work done
  --Linus Torvalds--

- Original Message -
From: John Townsend [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, August 29, 2001 12:54 PM
Subject: Dynamic Form Beans?


 I am working on a project where is would be nice to have the ability
to
 define a dynamic form bean (i.e. a form bean where the fields are
 defined at runtime). The most obvious (but perhaps not the best)
 solution to this problem would be if the ActionServlet could handle
 saving data in a form bean that was a hashtable.

 Has someone else run into this problem and come up with a solution?

 Thanks,
 -- John Townsend





Re: null pointer error

2001-06-27 Thread John Townsend



I think you have to have the html:text tag inside an 
html:html tag. For example:

html:html
 html:text property = "username" size = 
"20" maxlength = "20" value = "test"
/html:text
/html:html

I think that might be the source of your problem.


-- John Townsend


  - Original Message - 
  From: 
  Nick Chalko 

  To: [EMAIL PROTECTED] 
  
  Sent: Wednesday, June 27, 2001 11:53 
  AM
  Subject: null pointer error 
  
  My jsp page 
  with the following tag
  html:text 
  property="username" size="20" maxlength="20" value="test" 
  inside/html:txt
  
  generates the 
  following java code (from VAJ 3.5.3)
   do 
  { 
  // 
  end 
  out.print(_jspx_html_data[4]); 
  // begin 
  [file="C:\\login.jsp";from=(16,0);to=(16,69)] 
  /*  html:text  
  */ 
  org.apache.struts.taglib.html.TextTag _jspx_th_html_text_1 = new 
  org.apache.struts.taglib.html.TextTag(); 
  _jspx_th_html_text_1.setPageContext(pageContext); 
  _jspx_th_html_text_1.setParent(_jspx_th_html_form_2); 
  JspRuntimeLibrary.introspecthelper(_jspx_th_html_text_1, 
  "maxlength","20",null,null, 
  false); 
  JspRuntimeLibrary.introspecthelper(_jspx_th_html_text_1, 
  "property","username",null,null, 
  false); 
  JspRuntimeLibrary.introspecthelper(_jspx_th_html_text_1, 
  "size","20",null,null, 
  false); 
  JspRuntimeLibrary.introspecthelper(_jspx_th_html_text_1, 
  "value","test",null,null, 
  false); 
  try 
  { 
  int _jspx_eval_html_text_1 = 
  _jspx_th_html_text_1.doStartTag(); 
  if (_jspx_eval_html_text_1 == 
  Tag.EVAL_BODY_INCLUDE) 
  throw new JspTagException("Since tag handler class 
  org.apache.struts.taglib.html.TextTag implements BodyTag, it can't return 
  Tag.EVAL_BODY_INCLUDE"); 
  if (_jspx_eval_html_text_1 != Tag.SKIP_BODY) 
  { 
  try 
  { 
  if (_jspx_eval_html_text_1 != Tag.EVAL_BODY_INCLUDE) {
  // the next nile sets out to 
  null 
  out = 
  pageContext.pushBody(); 
  _jspx_th_html_text_1.setBodyContent((BodyContent) 
  out); 
  } 
  _jspx_th_html_text_1.doInitBody(); 
  do 
  { 
  // 
  end 
  out.print(_jspx_html_data[5]); 
  // begin 
  [file="C:\\login.jsp";from=(25,0);to=(25,0)] 
  } while (_jspx_th_html_text_1.doAfterBody() == 
  BodyTag.EVAL_BODY_TAG); 
  } finally 
  { 
  if (_jspx_eval_html_text_1 != 
  Tag.EVAL_BODY_INCLUDE) 
  out = 
  pageContext.popBody(); 
  } 
  } 
  if (_jspx_th_html_text_1.doEndTag() == 
  Tag.SKIP_PAGE) 
  return; 
  } finally 
  { 
  _jspx_th_html_text_1.release(); 
  }
  
  
  The proplem 
  is pageContext.pushBody() returns null which then fails the next time 
  something is written to out.
  Any ideas. 
  
  
  R,
  Nick