Re: Dynamic form actions

2003-03-14 Thread Jose Gonzalez Gomez
   Mark,

   Please, correct me if I'm wrong, but I think the action attribute in 
the html:form tag is a run time expression, so there's no need to 
extend the FormTag class in order to use a dynamic form action.

   Regards
   Jose
Mark wrote:

I just wanted to pass on a tidbit that might help one or two people out there.

I have a search page that displays the results with checkboxes.  There are two or three different places that i use this same search page, so rather than writing or copying the search results jsp page to several copies (to allow me to post the form thats on the results page to a different forward definition) i made a modifiecation to struts.

In the FormTag.java I added some code to peek in the formbean for a property called formaction.  If it finds one, it uses this new action instead of the hard coded one in the jsp page.

Thus, in my action class i do this:

MyBean myBean=(MyBean)actionForm;

myBean.setFormaction(/Some/other/url);
return mapping.findforward(default);
now i have a jsp page which i can reuse its functionality in several places in my code.

I had thought about using a hidden field, but the problem really stems from the statically coded form action=/Url part.  Since struts doesnt allow us much flexibility here by default, I decided to add my own and it works great!

Regards,
Mark


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Dynamic form actions

2003-03-14 Thread Mark
No, its not a runtime expression.

If you look at the code in FormTag you'll see that its not

 results.append(\ action=\);
 results.append(response.encodeURL(RequestUtils.getActionMappingURL(action, 
pageContext)));
 results.append(\);


It simply pulls the action mapping from the config.

I changed my code to

 results.append(\ action=\);
   // check if we have a bean thats exposing a formaction property, if so, use that 
property, otherwise use our assigned action value in the jsp page

 try {
Object value = RequestUtils.lookup(pageContext, beanName,formaction, null);
if (value != null  !value.toString().equals())
{
  this.action=ResponseUtils.filter(value.toString());
  System.out.println(value.toString());
}
  } catch (Exception e)
  {
e.printStackTrace();
  }
 results.append(response.encodeURL(RequestUtils.getActionMappingURL(action, 
pageContext)));


*** REPLY SEPARATOR  ***

On 03/14/2003 at 9:50 AM Jose Gonzalez Gomez wrote:

Mark,

Please, correct me if I'm wrong, but I think the action attribute in
the html:form tag is a run time expression, so there's no need to
extend the FormTag class in order to use a dynamic form action.

Regards
Jose

Mark wrote:

I just wanted to pass on a tidbit that might help one or two people out there.

I have a search page that displays the results with checkboxes.  There are two or 
three different places that i use this same search page, so rather than writing or 
copying the search results jsp page to several copies (to allow me to post the form 
thats on the results page to a different forward definition) i made a modifiecation 
to struts.

In the FormTag.java I added some code to peek in the formbean for a property called 
formaction.  If it finds one, it uses this new action instead of the hard coded 
one in the jsp page.

Thus, in my action class i do this:

MyBean myBean=(MyBean)actionForm;

myBean.setFormaction(/Some/other/url);
return mapping.findforward(default);

now i have a jsp page which i can reuse its functionality in several places in my 
code.

I had thought about using a hidden field, but the problem really stems from the 
statically coded form action=/Url part.  Since struts doesnt allow us much 
flexibility here by default, I decided to add my own and it works great!

Regards,
Mark




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Dynamic form actions

2003-03-14 Thread Kris Schneider
The code you've quoted has no impact on whether or not the html:form tag's
action attribute is an rtexpr. Look at struts-html.tld:

tag
  nameform/name
  tagclassorg.apache.struts.taglib.html.FormTag/tagclass
  bodycontentJSP/bodycontent
  attribute
nameaction/name
requiredtrue/required
rtexprvaluetrue/rtexprvalue
  /attribute
...

Quoting Mark [EMAIL PROTECTED]:

 No, its not a runtime expression.
 
 If you look at the code in FormTag you'll see that its not
 
  results.append(\ action=\);
 
 results.append(response.encodeURL(RequestUtils.getActionMappingURL(action,
 pageContext)));
  results.append(\);
 
 
 It simply pulls the action mapping from the config.
 
 I changed my code to 
 
  results.append(\ action=\);
// check if we have a bean thats exposing a formaction property, if so,
 use that property, otherwise use our assigned action value in the jsp page
 
  try {
 Object value = RequestUtils.lookup(pageContext,
 beanName,formaction, null);
 if (value != null  !value.toString().equals())
 {
   this.action=ResponseUtils.filter(value.toString());
   System.out.println(value.toString());
 }
   } catch (Exception e)
   {
 e.printStackTrace();
   }
 
 results.append(response.encodeURL(RequestUtils.getActionMappingURL(action,
 pageContext)));
 
 
 *** REPLY SEPARATOR  ***
 
 On 03/14/2003 at 9:50 AM Jose Gonzalez Gomez wrote:
 
 Mark,
 
 Please, correct me if I'm wrong, but I think the action attribute in 
 the html:form tag is a run time expression, so there's no need to 
 extend the FormTag class in order to use a dynamic form action.
 
 Regards
 Jose
 
 Mark wrote:
 
 I just wanted to pass on a tidbit that might help one or two people out
 there.
 
 I have a search page that displays the results with checkboxes.  There are
 two or three different places that i use this same search page, so rather
 than writing or copying the search results jsp page to several copies (to
 allow me to post the form thats on the results page to a different forward
 definition) i made a modifiecation to struts.
 
 In the FormTag.java I added some code to peek in the formbean for a
 property called formaction.  If it finds one, it uses this new action
 instead of the hard coded one in the jsp page.
 
 Thus, in my action class i do this:
 
 MyBean myBean=(MyBean)actionForm;
 
 myBean.setFormaction(/Some/other/url);
 return mapping.findforward(default);
 
 now i have a jsp page which i can reuse its functionality in several places
 in my code.
 
 I had thought about using a hidden field, but the problem really stems from
 the statically coded form action=/Url part.  Since struts doesnt allow us
 much flexibility here by default, I decided to add my own and it works
 great!
 
 Regards,
 Mark
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
   
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-- 
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Dynamic form actions

2003-03-14 Thread Mark
All that means is you can have

mysimpleTag value=%=scripletVariable%/

false means you cannot have a scriplet variable as a value

That's not quite what i wanted to do, but in a way accomplishes a similar task without 
modifying struts.  Its not sexy enough for me ;)

The whole point of MVC is seperation presentation, business logic, code

html:form 
action=%=request.getAttribute(formaction)!=null?(String)request.getAttribute(formaction):/Default/url%
 method=post/

If i start putting scriptlets like that in my code, im basically breaking the MVC 
design pattern.  Because now, my JSP page is dependent upon that scriptlet variable 
being in the environment, and if it used an object, say like this:

html:form 
action=%=request.getAttribute(myForm)!=null?(MyForm)request.getAttribute(formaction).getFormaction():/Default/url%
 method=post/


The method I used, I believe, is a tad better because the JSP page will still function 
in the absence of that scriptlet variable, and is cleaner JSP code.

Regards,
Mark


*** REPLY SEPARATOR  ***

On 03/14/2003 at 9:27 AM Kris Schneider wrote:

The code you've quoted has no impact on whether or not the html:form tag's
action attribute is an rtexpr. Look at struts-html.tld:

tag
  nameform/name
  tagclassorg.apache.struts.taglib.html.FormTag/tagclass
  bodycontentJSP/bodycontent
  attribute
nameaction/name
requiredtrue/required
rtexprvaluetrue/rtexprvalue
  /attribute
...

Quoting Mark [EMAIL PROTECTED]:

 No, its not a runtime expression.

 If you look at the code in FormTag you'll see that its not

  results.append(\ action=\);

 results.append(response.encodeURL(RequestUtils.getActionMappingURL(action,
 pageContext)));
  results.append(\);


 It simply pulls the action mapping from the config.

 I changed my code to

  results.append(\ action=\);
// check if we have a bean thats exposing a formaction property, if so,
 use that property, otherwise use our assigned action value in the jsp page

  try {
 Object value = RequestUtils.lookup(pageContext,
 beanName,formaction, null);
 if (value != null  !value.toString().equals())
 {
   this.action=ResponseUtils.filter(value.toString());
   System.out.println(value.toString());
 }
   } catch (Exception e)
   {
 e.printStackTrace();
   }

 results.append(response.encodeURL(RequestUtils.getActionMappingURL(action,
 pageContext)));


 *** REPLY SEPARATOR  ***

 On 03/14/2003 at 9:50 AM Jose Gonzalez Gomez wrote:

 Mark,
 
 Please, correct me if I'm wrong, but I think the action attribute in
 the html:form tag is a run time expression, so there's no need to
 extend the FormTag class in order to use a dynamic form action.
 
 Regards
 Jose
 
 Mark wrote:
 
 I just wanted to pass on a tidbit that might help one or two people out
 there.
 
 I have a search page that displays the results with checkboxes.  There are
 two or three different places that i use this same search page, so rather
 than writing or copying the search results jsp page to several copies (to
 allow me to post the form thats on the results page to a different forward
 definition) i made a modifiecation to struts.
 
 In the FormTag.java I added some code to peek in the formbean for a
 property called formaction.  If it finds one, it uses this new action
 instead of the hard coded one in the jsp page.
 
 Thus, in my action class i do this:
 
 MyBean myBean=(MyBean)actionForm;
 
 myBean.setFormaction(/Some/other/url);
 return mapping.findforward(default);
 
 now i have a jsp page which i can reuse its functionality in several places
 in my code.
 
 I had thought about using a hidden field, but the problem really stems from
 the statically coded form action=/Url part.  Since struts doesnt allow us
 much flexibility here by default, I decided to add my own and it works
 great!
 
 Regards,
 Mark
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



--
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Dynamic form actions

2003-03-14 Thread Kris Schneider
Right, so you'd put the code to determine the appropriate value for the action
attribute in your action, not in a JSP expression. That value could be stored in
a request attribute and accessed simply as:

html:form action='%= request.getAttribute(formaction) %'

html-el:form might even let you do (never used it):

html-el:form action=${formaction}

Of course, this assumes you're doing the MVC thing of disallowing direct client
access to your JSP pages. It just seems confusing to have an attribute that may
or may not be used. I'd rather have the attribute value always static or always
dynamic. But that's personal preference, I really just wanted to correct the
statement about the request-time value. Whether that's of any use in your case
is another issue.

Quoting Mark [EMAIL PROTECTED]:

 All that means is you can have
 
 mysimpleTag value=%=scripletVariable%/
 
 false means you cannot have a scriplet variable as a value
 
 That's not quite what i wanted to do, but in a way accomplishes a similar
 task without modifying struts.  Its not sexy enough for me ;)
 
 The whole point of MVC is seperation presentation, business logic, code
 
 html:form

action=%=request.getAttribute(formaction)!=null?(String)request.getAttribute(formaction):/Default/url%
 method=post/
 
 If i start putting scriptlets like that in my code, im basically breaking the
 MVC design pattern.  Because now, my JSP page is dependent upon that
 scriptlet variable being in the environment, and if it used an object, say
 like this:
 
 html:form

action=%=request.getAttribute(myForm)!=null?(MyForm)request.getAttribute(formaction).getFormaction():/Default/url%
 method=post/
 
 
 The method I used, I believe, is a tad better because the JSP page will still
 function in the absence of that scriptlet variable, and is cleaner JSP
 code.
 
 Regards,
 Mark
 
 
 *** REPLY SEPARATOR  ***
 
 On 03/14/2003 at 9:27 AM Kris Schneider wrote:
 
 The code you've quoted has no impact on whether or not the html:form
 tag's
 action attribute is an rtexpr. Look at struts-html.tld:
 
 tag
   nameform/name
   tagclassorg.apache.struts.taglib.html.FormTag/tagclass
   bodycontentJSP/bodycontent
   attribute
 nameaction/name
 requiredtrue/required
 rtexprvaluetrue/rtexprvalue
   /attribute
 ...
 
 Quoting Mark [EMAIL PROTECTED]:
 
  No, its not a runtime expression.
  
  If you look at the code in FormTag you'll see that its not
  
   results.append(\ action=\);
  
 
 results.append(response.encodeURL(RequestUtils.getActionMappingURL(action,
  pageContext)));
   results.append(\);
  
  
  It simply pulls the action mapping from the config.
  
  I changed my code to 
  
   results.append(\ action=\);
 // check if we have a bean thats exposing a formaction property, if
 so,
  use that property, otherwise use our assigned action value in the jsp
 page
  
   try {
  Object value = RequestUtils.lookup(pageContext,
  beanName,formaction, null);
  if (value != null  !value.toString().equals())
  {
this.action=ResponseUtils.filter(value.toString());
System.out.println(value.toString());
  }
} catch (Exception e)
{
  e.printStackTrace();
}
  
 
 results.append(response.encodeURL(RequestUtils.getActionMappingURL(action,
  pageContext)));
  
  
  *** REPLY SEPARATOR  ***
  
  On 03/14/2003 at 9:50 AM Jose Gonzalez Gomez wrote:
  
  Mark,
  
  Please, correct me if I'm wrong, but I think the action attribute in
 
  the html:form tag is a run time expression, so there's no need to 
  extend the FormTag class in order to use a dynamic form action.
  
  Regards
  Jose
  
  Mark wrote:
  
  I just wanted to pass on a tidbit that might help one or two people
 out
  there.
  
  I have a search page that displays the results with checkboxes.  There
 are
  two or three different places that i use this same search page, so
 rather
  than writing or copying the search results jsp page to several copies
 (to
  allow me to post the form thats on the results page to a different
 forward
  definition) i made a modifiecation to struts.
  
  In the FormTag.java I added some code to peek in the formbean for a
  property called formaction.  If it finds one, it uses this new action
  instead of the hard coded one in the jsp page.
  
  Thus, in my action class i do this:
  
  MyBean myBean=(MyBean)actionForm;
  
  myBean.setFormaction(/Some/other/url);
  return mapping.findforward(default);
  
  now i have a jsp page which i can reuse its functionality in several
 places
  in my code.
  
  I had thought about using a hidden field, but the problem really stems
 from
  the statically coded form action=/Url part.  Since struts doesnt allow
 us
  much flexibility here by default, I decided to add my own and it works
  great!
  
  Regards,
  Mark
  
  
  
  
  

Re: Dynamic form actions

2003-03-14 Thread Mark
thanks,  good ideas

*** REPLY SEPARATOR  ***

On 03/14/2003 at 10:24 AM Kris Schneider wrote:

Right, so you'd put the code to determine the appropriate value for the action
attribute in your action, not in a JSP expression. That value could be stored in
a request attribute and accessed simply as:

html:form action='%= request.getAttribute(formaction) %'

html-el:form might even let you do (never used it):

html-el:form action=${formaction}

Of course, this assumes you're doing the MVC thing of disallowing direct client
access to your JSP pages. It just seems confusing to have an attribute that may
or may not be used. I'd rather have the attribute value always static or always
dynamic. But that's personal preference, I really just wanted to correct the
statement about the request-time value. Whether that's of any use in your case
is another issue.

Quoting Mark [EMAIL PROTECTED]:

 All that means is you can have

 mysimpleTag value=%=scripletVariable%/

 false means you cannot have a scriplet variable as a value

 That's not quite what i wanted to do, but in a way accomplishes a similar
 task without modifying struts.  Its not sexy enough for me ;)

 The whole point of MVC is seperation presentation, business logic, code

 html:form

action=%=request.getAttribute(formaction)!=null?(String)request.getAttribute(formaction):/Default/url%
 method=post/

 If i start putting scriptlets like that in my code, im basically breaking the
 MVC design pattern.  Because now, my JSP page is dependent upon that
 scriptlet variable being in the environment, and if it used an object, say
 like this:

 html:form

action=%=request.getAttribute(myForm)!=null?(MyForm)request.getAttribute(formaction).getFormaction():/Default/url%
 method=post/


 The method I used, I believe, is a tad better because the JSP page will still
 function in the absence of that scriptlet variable, and is cleaner JSP
 code.

 Regards,
 Mark


 *** REPLY SEPARATOR  ***

 On 03/14/2003 at 9:27 AM Kris Schneider wrote:

 The code you've quoted has no impact on whether or not the html:form
 tag's
 action attribute is an rtexpr. Look at struts-html.tld:
 
 tag
   nameform/name
   tagclassorg.apache.struts.taglib.html.FormTag/tagclass
   bodycontentJSP/bodycontent
   attribute
 nameaction/name
 requiredtrue/required
 rtexprvaluetrue/rtexprvalue
   /attribute
 ...
 
 Quoting Mark [EMAIL PROTECTED]:
 
  No, its not a runtime expression.
 
  If you look at the code in FormTag you'll see that its not
 
   results.append(\ action=\);
 
 
 results.append(response.encodeURL(RequestUtils.getActionMappingURL(action,
  pageContext)));
   results.append(\);
 
 
  It simply pulls the action mapping from the config.
 
  I changed my code to
 
   results.append(\ action=\);
 // check if we have a bean thats exposing a formaction property, if
 so,
  use that property, otherwise use our assigned action value in the jsp
 page
 
   try {
  Object value = RequestUtils.lookup(pageContext,
  beanName,formaction, null);
  if (value != null  !value.toString().equals())
  {
this.action=ResponseUtils.filter(value.toString());
System.out.println(value.toString());
  }
} catch (Exception e)
{
  e.printStackTrace();
}
 
 
 results.append(response.encodeURL(RequestUtils.getActionMappingURL(action,
  pageContext)));
 
 
  *** REPLY SEPARATOR  ***
 
  On 03/14/2003 at 9:50 AM Jose Gonzalez Gomez wrote:
 
  Mark,
  
  Please, correct me if I'm wrong, but I think the action attribute in

  the html:form tag is a run time expression, so there's no need to
  extend the FormTag class in order to use a dynamic form action.
  
  Regards
  Jose
  
  Mark wrote:
  
  I just wanted to pass on a tidbit that might help one or two people
 out
  there.
  
  I have a search page that displays the results with checkboxes.  There
 are
  two or three different places that i use this same search page, so
 rather
  than writing or copying the search results jsp page to several copies
 (to
  allow me to post the form thats on the results page to a different
 forward
  definition) i made a modifiecation to struts.
  
  In the FormTag.java I added some code to peek in the formbean for a
  property called formaction.  If it finds one, it uses this new action
  instead of the hard coded one in the jsp page.
  
  Thus, in my action class i do this:
  
  MyBean myBean=(MyBean)actionForm;
  
  myBean.setFormaction(/Some/other/url);
  return mapping.findforward(default);
  
  now i have a jsp page which i can reuse its functionality in several
 places
  in my code.
  
  I had thought about using a hidden field, but the problem really stems
 from
  the statically coded form action=/Url part.  Since struts doesnt allow
 us
  much flexibility here by default, I decided to add my own and it works
  great!
  
  Regards,
  Mark
  
  

Dynamic form actions

2003-03-13 Thread Mark
I just wanted to pass on a tidbit that might help one or two people out there.

I have a search page that displays the results with checkboxes.  There are two or 
three different places that i use this same search page, so rather than writing or 
copying the search results jsp page to several copies (to allow me to post the form 
thats on the results page to a different forward definition) i made a modifiecation to 
struts.

In the FormTag.java I added some code to peek in the formbean for a property called 
formaction.  If it finds one, it uses this new action instead of the hard coded one 
in the jsp page.

Thus, in my action class i do this:

MyBean myBean=(MyBean)actionForm;

myBean.setFormaction(/Some/other/url);
return mapping.findforward(default);

now i have a jsp page which i can reuse its functionality in several places in my code.

I had thought about using a hidden field, but the problem really stems from the 
statically coded form action=/Url part.  Since struts doesnt allow us much 
flexibility here by default, I decided to add my own and it works great!

Regards,
Mark




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Dynamic form actions

2003-03-13 Thread Richard Raquepo
We'll i kind of interested in trying your solution.
Can you post some jsp  codes in here.
I think many people will appreciate it.

Thanks.
- Original Message -
From: Mark [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 14, 2003 11:52 AM
Subject: Dynamic form actions


I just wanted to pass on a tidbit that might help one or two people out
there.

I have a search page that displays the results with checkboxes.  There are
two or three different places that i use this same search page, so rather
than writing or copying the search results jsp page to several copies (to
allow me to post the form thats on the results page to a different forward
definition) i made a modifiecation to struts.

In the FormTag.java I added some code to peek in the formbean for a property
called formaction.  If it finds one, it uses this new action instead of
the hard coded one in the jsp page.

Thus, in my action class i do this:

MyBean myBean=(MyBean)actionForm;

myBean.setFormaction(/Some/other/url);
return mapping.findforward(default);

now i have a jsp page which i can reuse its functionality in several places
in my code.

I had thought about using a hidden field, but the problem really stems from
the statically coded form action=/Url part.  Since struts doesnt allow us
much flexibility here by default, I decided to add my own and it works
great!

Regards,
Mark




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]