Trick question, Can I pass multiple values to setter getter methods??

2003-09-29 Thread Shah, Shrihas (OFT)
Hi:

 

In my jsp if I have 

 



 

And in my form if I have 

 

  public String getTopping(String t1)

  {

return t1;

  }

  public void setTopping(String t1,String value)

  {

  }

 

Then it works fine, but If I want to pass another parameter then it says
that no getter method found. How can I pass multiple variables in
property like the way I am doing below.

 



 

And in form

 

  public String getTopping(String t1, String t2)

  {

return "t1";

  }

  public void setTopping(String t1,String t2,String value)

  {

  }

 

Thanks in Advance. The reason I want to do is that I want to store this
in a multilevel hashtable in my setTopping method(I have not shown the
code here). But I was just wonder that is it possible?

 

Thanks

 

Sincerely,

 

Shrihas

 

 

Shrihas Shah
NYS Office for Technology
[EMAIL PROTECTED]
Phone (518) 408-2382
Fax (518) 473-3389
(US Postal Service Regular Mail Address)
State Capitol ESP, PO Box 2062
Albany, NY 12220-0062
(Parcel Post/Overnight and Interagency Mail Address)
Empire State Plaza
Swan St., Core 4, 1st Floor
Albany, NY 12223

 



Re: calling getter methods

2001-03-22 Thread Ken Beyer

Also, I found using the debug level (and adding my own
debug messages where needed) to be useful in seeing
when things are getting called.

Ken

"Craig R. McClanahan" wrote:

> On Wed, 21 Mar 2001, G.L. Grobe wrote:
>
> > I can see that for a radio tag, the property is the name of the bean that
> > was mapped in the struts-config.xml file. But how does the getter method in
> > the action form bean actually get called, or how does the app know which
> > getter method to use?
> >
> > I have a working example where my  action does a getXXX on the form action,
> > but I don't know how it got filled in and would like to understand that.
> >
>
> Basically, Struts follows rules very similar to what the standard
>
> 
>
> tag does.  It looks at the request parameters, and matches them up with
> JavaBeans and setter methods, as long as your bean's setter methods match
> the rules in the JavaBeans specification.  In most cases, that means a
> proeprty named "foo" will look for a setter named "setFoo" -- but see the
> JavaBeans Specification for more info.
>
> > Adv(Thnxs)ance
> >
> >
>
> Craig

--
Ken Beyer
Metatec Internet Products Group
[EMAIL PROTECTED]  |  http://www.metatec.com/
"The box said 'Requires Windows 95 or better.' - so I installed Linux."






Re: calling getter methods

2001-03-21 Thread Craig R. McClanahan



On Wed, 21 Mar 2001, G.L. Grobe wrote:

> I can see that for a radio tag, the property is the name of the bean that
> was mapped in the struts-config.xml file. But how does the getter method in
> the action form bean actually get called, or how does the app know which
> getter method to use?
> 
> I have a working example where my  action does a getXXX on the form action,
> but I don't know how it got filled in and would like to understand that.
> 

Basically, Struts follows rules very similar to what the standard



tag does.  It looks at the request parameters, and matches them up with
JavaBeans and setter methods, as long as your bean's setter methods match
the rules in the JavaBeans specification.  In most cases, that means a
proeprty named "foo" will look for a setter named "setFoo" -- but see the
JavaBeans Specification for more info.

> Adv(Thnxs)ance
> 
> 

Craig





calling getter methods

2001-03-21 Thread G.L. Grobe

I can see that for a radio tag, the property is the name of the bean that
was mapped in the struts-config.xml file. But how does the getter method in
the action form bean actually get called, or how does the app know which
getter method to use?

I have a working example where my  action does a getXXX on the form action,
but I don't know how it got filled in and would like to understand that.

Adv(Thnxs)ance




Re: getter methods ...

2001-03-21 Thread Maya Muchnik


Hi,
I think you need to change or property name to view or change getter/setter
and other stuff. See below in red.
Maya
"G.L. Grobe" wrote:
I'm new to struts and trying to get my index.jsp
to show up, but instead I
get the following error:
500 Internal Server Error
javax.servlet.jsp.JspException: No getter method available for property
View
for bean under name org.apache.struts.taglib.html.BEAN at
org.apache.struts.taglib.html.RadioTag.doStartTag(RadioTag.java, Compiled
Code) at /index.jsp._jspService(/index.jsp.java, Compiled Code) at
com.orionserver.http.OrionHttpJspPage.service(JAX, Compiled Code) at
com.evermind.server.http.HttpApplication.xj(JAX, Compiled Code) at
com.evermind.server.http.JSPServlet.service(JAX, Compiled Code) at
com.evermind.server.http.d3.sw(JAX, Compiled Code) at
com.evermind.server.http.d3.su(JAX, Compiled Code) at
com.evermind.server.http.ef.s1(JAX, Compiled Code) at
com.evermind.server.http.ef.do(JAX, Compiled Code) at
com.evermind.util.f.run(JAX, Compiled Code)
Somehow I think the ViewForm bean is not being found as I've got the
properties included, but it seems to be defaulting to another bean.
I don't
think I've got to map the properties to the bean, as they map automatically
to the bean in the action form, right?
I've included all my files trying to get a simple example going.
Any help much appreciated.
- ViewForm.java -
package com.neuroquest.cais.actions;
import org.apache.struts.action.ActionForm;
public class ViewForm extends ActionForm
{
   protected String viewName;
   public String getViewName()
{
  return viewName;
   }
   public void setViewName(String
view) {
  this.viewName = view;
   }
}
- ViewAction.java -
package com.neuroquest.cais.actions;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class ViewAction extends Action
{
   public ActionForward perform(ActionMapping mapping, ActionForm
form,
 HttpServletRequest
request, HttpServletResponse response) {
  // turn form instance into custom form
bean.
  ViewForm viewForm = (ViewForm) form;
  String viewName = viewForm.getView();
  if (viewName.equals("Master View")) {
 return mapping.findForward("master");
  }
  else if (viewName.equals("Details View"))
{
 return mapping.findForward("details");
  }
  return mapping.findForward("error");
   }
}
- inside my web.xml -
  
  action
  org.apache.struts.action.ActionServlet
  
 application
 com.neuroquest.cais.resources.cais
  
  
 config
 /WEB-INF/struts-config.xml
  
  
 validate
 true
  
  
  1
   
   
  action
  *.do
   
- struts-config.xml -

Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">


   
   type="com.neuroquest.cais.actions.ViewForm"
/>
   
   
   
   name="viewForm">
 
 
 
  
   

 inside my index.jsp 



   
  
 
  
 
  
  
 
 
 
  
   
   
  
 
 
 
  
   






Re: getter methods ...

2001-03-20 Thread G.L. Grobe

Thanxs, I thought it was supposed to be the same case as what was in the
getter method.

Thnxs again.

- Original Message -
From: "Matthew O'Haire" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, March 20, 2001 9:56 PM
Subject: RE: getter methods ...


>
> Hi,
>
> I think the culprit is in your JSP..
>
> 
>
> The property names are case-sensitive.  Try property="view".
>




RE: getter methods ...

2001-03-20 Thread Matthew O'Haire


Hi,

I think the culprit is in your JSP..



The property names are case-sensitive.  Try property="view".




getter methods ...

2001-03-20 Thread G.L. Grobe

I'm new to struts and trying to get my index.jsp to show up, but instead I
get the following error:

500 Internal Server Error
javax.servlet.jsp.JspException: No getter method available for property View
for bean under name org.apache.struts.taglib.html.BEAN at
org.apache.struts.taglib.html.RadioTag.doStartTag(RadioTag.java, Compiled
Code) at /index.jsp._jspService(/index.jsp.java, Compiled Code) at
com.orionserver.http.OrionHttpJspPage.service(JAX, Compiled Code) at
com.evermind.server.http.HttpApplication.xj(JAX, Compiled Code) at
com.evermind.server.http.JSPServlet.service(JAX, Compiled Code) at
com.evermind.server.http.d3.sw(JAX, Compiled Code) at
com.evermind.server.http.d3.su(JAX, Compiled Code) at
com.evermind.server.http.ef.s1(JAX, Compiled Code) at
com.evermind.server.http.ef.do(JAX, Compiled Code) at
com.evermind.util.f.run(JAX, Compiled Code)

Somehow I think the ViewForm bean is not being found as I've got the
properties included, but it seems to be defaulting to another bean. I don't
think I've got to map the properties to the bean, as they map automatically
to the bean in the action form, right?
I've included all my files trying to get a simple example going.
Any help much appreciated.

- ViewForm.java -
package com.neuroquest.cais.actions;

import org.apache.struts.action.ActionForm;

public class ViewForm extends ActionForm
{
   protected String viewName;

   public String getView() {
  return viewName;
   }

   public void setView(String view) {
  this.viewName = view;
   }
}
- ViewAction.java -
package com.neuroquest.cais.actions;

import javax.servlet.http.*;
import org.apache.struts.action.*;

public class ViewAction extends Action
{
   public ActionForward perform(ActionMapping mapping, ActionForm form,
 HttpServletRequest request, HttpServletResponse response) {

  // turn form instance into custom form bean.
  ViewForm viewForm = (ViewForm) form;

  String viewName = viewForm.getView();

  if (viewName.equals("Master View")) {
 return mapping.findForward("master");
  }
  else if (viewName.equals("Details View")) {
 return mapping.findForward("details");
  }

  return mapping.findForward("error");
   }
}

- inside my web.xml -

  
  action
  org.apache.struts.action.ActionServlet
  
 application
 com.neuroquest.cais.resources.cais
  
  
 config
 /WEB-INF/struts-config.xml
  
  
 validate
 true
  
  
  1
   

   
  action
  *.do
   

- struts-config.xml -


http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">




   
  
   

   

   
  

 
 
 

  
   


 inside my index.jsp 





   
  
 
  
 
  
  
 
 
 
  
   
   
  
 
 
 
  
   











Re: PropertyUtils handling multiple getter methods

2000-12-28 Thread Chandan Kulkarni



Thanks for the explanation...
 
I mistyped in my mail before - I did have 2 getters for the 
getItems(), one simple and one indexed.
 
After writing the mail I did write a test and I did 
figure out I had misunderstood the code getPropertyDescriptors gets one 
descriptor for each property -  not 2 if there are 2 
getters...
 
It turns out the only changes I need to make are to  
BeanUtils.java to handle setting of  indexed  and 
nested properties within a 
 
Thanks again,
 
    -Chandan.

  -Original Message-From: 
  Craig R. McClanahan <[EMAIL PROTECTED]>To: 
  [EMAIL PROTECTED] 
  <[EMAIL PROTECTED]>Cc: 
  [EMAIL PROTECTED] 
  <[EMAIL PROTECTED]>; 
  Chandan Kulkarni <[EMAIL PROTECTED]>Date: 
  Thursday, December 28, 2000 5:04 PMSubject: Re: PropertyUtils 
  handling multiple getter methodsSee below. 
  Chandan Kulkarni wrote: 
    I had a question about this 
part of PropertyUtils.java.     public 
static PropertyDescriptor getPropertyDescriptor(Object bean, 
  
String name)   PropertyDescriptor descriptors[] = 
getPropertyDescriptors(bean);  if (descriptors == null)     return (null); 
 for (int i = 0; i < 
descriptors.length; i++) {  if 
(name.equals(descriptors[i].getName()))   
return (descriptors[i]);  
}The method 
getPropertyDescriptorcalls    
getPropertyDescriptors(bean)and iterates through them to get a match on the 
name. Incase the Bean class 
contains  ArrayList items; It requires to have 2 getItems methods 1)   ArrayList 
getItems() - to be used when you use 
the    
2)  It also 
requires an indexed getter    Item 
getItem(int index)    to handle the form input fields within 
the iterate tag. If you find the wrong descriptor 
first, you get a NoSuchMethodExceptionI propose getPropertyDescriptor take 
another parameter (which says whether its an Indexedproperty we are looking 
for) or create anothergetIndexedPropertyDescriptor. I'll probably do that to handle nested, indexed properties to get 
 to work...   -Chandan.
  PropertyUtils is using the standard JavaBeans introspection under the 
  covers, in order to identify the actual method names of the getters and 
  setters.  In particular, you are required to use the property naming 
  conventions outlined in the JavaBeans specification, version 1.0.1. 
  In your example above, you are using two different property names ("items" 
  versus "item"), so the introspection code will consider those to be two 
  different properties.  It is legal to provide both array-based and 
  index-based getters and setters for the same property, but you must use the 
  same name -- for example: 
      Item[] getItems();     Item 
  getItems(int index);     void setItems(Item items[]); 
      void setItems(int index, Item item); 
  If you do this, PropertyUtils uses the following algorithm to retrieve an 
  indexed property value at a particular subscript: * If there is an indexed 
  getter (Item getItems(int index)),   call it directly * 
  Otherwise, call the array getter (Item[] getItems()) and   access the 
  requested element out of the array. 
  Craig McClanahan   


Re: PropertyUtils handling multiple getter methods

2000-12-28 Thread Craig R. McClanahan



See below.
Chandan Kulkarni wrote:
  I had a question about this
part of PropertyUtils.java.    
public static PropertyDescriptor getPropertyDescriptor(Object bean,
 
String name)  
PropertyDescriptor descriptors[] = getPropertyDescriptors(bean);
 if (descriptors == null)
    return (null);
 for (int i = 0; i < descriptors.length;
i++) {
 if (name.equals(descriptors[i].getName()))
 
return (descriptors[i]);
 }The
method getPropertyDescriptorcalls   
getPropertyDescriptors(bean)and iterates through them to get a match on
the name. Incase the Bean class contains 
ArrayList items; It requires to have 2 getItems methods
1)   ArrayList getItems() - to be used when you use the   
2)  It also requires
an indexed getter    Item getItem(int
index)    to handle the form input fields within the iterate
tag. If you find the wrong descriptor first, you get
a NoSuchMethodExceptionI propose getPropertyDescriptor take another parameter
(which says whether its an Indexedproperty we are looking for) or create
anothergetIndexedPropertyDescriptor. I'll probably
do that to handle nested, indexed properties to get 
to work...   -Chandan.

PropertyUtils is using the standard JavaBeans introspection under
the covers, in order to identify the actual method names of the getters
and setters.  In particular, you are required to use the property
naming conventions outlined in the JavaBeans specification, version 1.0.1.
In your example above, you are using two different property names ("items"
versus "item"), so the introspection code will consider those to be two
different properties.  It is legal to provide both array-based and
index-based getters and setters for the same property, but you must use
the same name -- for example:
    Item[] getItems();
    Item getItems(int index);
    void setItems(Item items[]);
    void setItems(int index, Item item);
If you do this, PropertyUtils uses the following algorithm to retrieve
an indexed property value at a particular subscript:
* If there is an indexed getter (Item getItems(int index)),
  call it directly
* Otherwise, call the array getter (Item[] getItems()) and
  access the requested element out of the array.
Craig McClanahan
 




PropertyUtils handling multiple getter methods

2000-12-27 Thread Chandan Kulkarni



 
I had a question about this part of 
PropertyUtils.java.
 

 
        
public static PropertyDescriptor getPropertyDescriptor(Object 
bean,    
          String name)
 

 
     PropertyDescriptor descriptors[] = 
getPropertyDescriptors(bean);     if (descriptors == 
null)     return 
(null);     for (int i = 0; i < descriptors.length; 
i++) {     if 
(name.equals(descriptors[i].getName())) 
     return 
(descriptors[i]);     }

The method getPropertyDescriptor  

calls 
        
getPropertyDescriptors(bean)
and iterates through them to get a match on the 
name.
 
Incase the Bean class contains
      ArrayList items;
 
It requires to have 2 getItems methods
 1)   ArrayList getItems() - to be used when 
you use the 
            
 
2)  It also requires an indexed getter
        Item getItem(int 
index)
    to handle the form input fields within the 
iterate tag.
 
If you find the wrong descriptor first, you get a 
NoSuchMethodException
I propose getPropertyDescriptor take another parameter 
(which says whether its an  Indexed
property we are looking for) or create another
getIndexedPropertyDescriptor.
 
I'll probably do that to handle nested, indexed properties to 
get  to work...
 
  -Chandan.