Re: Easy form populate question for gurus

2005-05-22 Thread Randy Kennedy

Well, I finally figured out a solution to this problem outlined below.  Thought 
I would share it with the group in case someone else runs into this same 
problem.

The problem is somewhere between the Jakarta Commons BeanUtils in conjunction with a 
LazyValidatorForm.  Since the LazyValidatorForm class is all about being lazy (like 
me) where you don't have to define your fields unless they're associated with custom 
classes, there is a problem when you go to initialize the form with database data 
that contains null values.  I thought that since my value object had the fields 
defined as java.lang.String objects that they would be translated to that in the form 
object when using BeanUtils.copyProperties(...), but that's not always the case.  I 
had to actually use a  element in the LazyValidatorForm 
definition in the struts config file defining that the field is a String field.  This 
defeats the whole purpose for me using the LazyValidatorForm method in the first 
place.

Anyway, it fixed my problem, and it appears that I have to stop being lazy.  ;-(

--
Randy Kennedy
Software Engineer
Appriss, Inc. (Provider of the VINE Service)
10401 Linn Station Road, Suite 200
Louisville, KY  40223-3842

Web   : http://www.vineco.com, http://www.appriss.com
Email : [EMAIL PROTECTED]



Randy Kennedy wrote:



Here is a snippet from my initializing action before it goes to the 
form view:


...
   LazyValidatorForm ppForm = (LazyValidatorForm)form;
   ProtectedPersonLocal ppl = null;
   ProtectedPersonDTO dto = null;
   String sid = null;
 sid = request.getParameter("sid");
 ppl = 
(ProtectedPersonLocal)EJBHelper.getLocalInstance(ProtectedPersonLocalHome.JNDI_NAME); 


   dto = ppl.getProtectedPersonBySid(sid);
   BeanUtils.copyProperties(ppForm, dto);


The values in question are java.lang.String objects.  Should be basic 
stuff right?  I stepped through the debugger, and the 
LazyValidatorForm object is being set correctly for the null strings 
from my VO; however, when it comes to displaying the form for editing, 
the "null" fields contain an object reference like 
[EMAIL PROTECTED]  If I update the form with any type of text 
values, it'll show correctly the next time that I go to update the 
data.  It's only happening when there are null values involved.


Hubert Rabago wrote:


Please provide more information.  How is your form configured/written?
Are there "initial" values?  What is the type of the data from which
you're copying a value?

Hubert


On 5/20/05, Randy Kennedy <[EMAIL PROTECTED]> wrote:
 


Why does an object reference (e.g. [EMAIL PROTECTED]) show up in
my text fields when I prepopulate the form using Jakarta commons
BeanUtils.copyProperties(...)?  The values in the database are null, 
and
I know this has something to do with it, so I guess my real question 
is,

"How do I fix it?".

--
Randy Kennedy
Appriss, Inc.


  



--

Randy Kennedy
Software Engineer
Appriss, Inc. (Provider of the VINE Service)
10401 Linn Station Road, Suite 200
Louisville, KY  40223-3842

Web   : http://www.vineco.com, http://www.appriss.com
Email : [EMAIL PROTECTED]





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



Re: Easy form populate question for gurus

2005-05-20 Thread Randy Kennedy
Here is a snippet from my initializing action before it goes to the form 
view:

...
   LazyValidatorForm ppForm = (LazyValidatorForm)form;
   ProtectedPersonLocal ppl = null;
   ProtectedPersonDTO dto = null;
   String sid = null;
  
   sid = request.getParameter("sid");
  
   ppl = 
(ProtectedPersonLocal)EJBHelper.getLocalInstance(ProtectedPersonLocalHome.JNDI_NAME);
   dto = ppl.getProtectedPersonBySid(sid);
   BeanUtils.copyProperties(ppForm, dto);


The values in question are java.lang.String objects.  Should be basic 
stuff right?  I stepped through the debugger, and the LazyValidatorForm 
object is being set correctly for the null strings from my VO; however, 
when it comes to displaying the form for editing, the "null" fields 
contain an object reference like [EMAIL PROTECTED]  If I update 
the form with any type of text values, it'll show correctly the next 
time that I go to update the data.  It's only happening when there are 
null values involved.

Hubert Rabago wrote:
Please provide more information.  How is your form configured/written?
Are there "initial" values?  What is the type of the data from which
you're copying a value?
Hubert
On 5/20/05, Randy Kennedy <[EMAIL PROTECTED]> wrote:
 

Why does an object reference (e.g. [EMAIL PROTECTED]) show up in
my text fields when I prepopulate the form using Jakarta commons
BeanUtils.copyProperties(...)?  The values in the database are null, and
I know this has something to do with it, so I guess my real question is,
"How do I fix it?".
--
Randy Kennedy
Appriss, Inc.
   

--
Randy Kennedy
Software Engineer
Appriss, Inc. (Provider of the VINE Service)
10401 Linn Station Road, Suite 200
Louisville, KY  40223-3842
Web   : http://www.vineco.com, http://www.appriss.com
Email : [EMAIL PROTECTED]

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


Easy form populate question for gurus

2005-05-20 Thread Randy Kennedy
Why does an object reference (e.g. [EMAIL PROTECTED]) show up in 
my text fields when I prepopulate the form using Jakarta commons 
BeanUtils.copyProperties(...)?  The values in the database are null, and 
I know this has something to do with it, so I guess my real question is, 
"How do I fix it?".

--
Randy Kennedy
Appriss, Inc.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: LookupDispatchAction - missing resource in key method map

2005-05-11 Thread Randy Kennedy
OkayI figured out what I was doing wrong, so I'm going to post this 
FYI out there just in case someone else makes the same mistake I did.

In my form, I had a hidden field with the same name as the parameter 
(e.g. methodToCall) defined in my action.  After my initialization 
action forwarded to the page, the hidden field was set with the 
parameter value I was passing in (e.g. methodToCall=addMemory).

When I clicked on the add button (button.respondent.add.memory), the 
"addMemory" value was passed to the LookupDispatchAction as the key to 
find the method to call instead of "button.respondent.add.memory".

Hope this explanation makes sense.  I figured it out once I downloaded 
the code and stepped through the code debug mode.

Randy Kennedy wrote:
I've banged my head on this problem for at least 4-5 hours, and I'm at 
my wits end.  I've already reviewed several possible solutions, but it 
appears that I have everything in order for using the 
LookupDispatchAction class.

Here's the message that I receive:
---
10:17:29,172 ERROR [Engine] StandardWrapperValve[action]: 
Servlet.service() for servlet action threw exception
javax.servlet.ServletException: Action[/postRespondentFormAction] 
missing resource 'addMemory' in key method map
---

Here is the excerpt from Application.resources:
---
button.respondent.add.memory = continue to protective order
---
Here is the excerpt from struts-config.xml:
---
 

 
---
My RespondentFormAction class extends the LookupDispatchAction class 
and has the addMemory method:

---
public ActionForward addMemory(ActionMapping mapping, ActionForm 
form, HttpServletRequest request, HttpServletResponse response) throws 
Exception { ... }
---

I also populate the map as such:
---
protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("button.pp.add", "add");
map.put("button.respondent.add.memory", "addMemory");
return map;
}
---
Funny thing is is that I have other LookupDispatchActions working 
correctly in other places.  I don't know what I'm overlooking and 
doing differently with this one.

Any suggestions?

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


LookupDispatchAction - missing resource in key method map

2005-05-11 Thread Randy Kennedy
I've banged my head on this problem for at least 4-5 hours, and I'm at 
my wits end.  I've already reviewed several possible solutions, but it 
appears that I have everything in order for using the 
LookupDispatchAction class.

Here's the message that I receive:
---
10:17:29,172 ERROR [Engine] StandardWrapperValve[action]: 
Servlet.service() for servlet action threw exception
javax.servlet.ServletException: Action[/postRespondentFormAction] 
missing resource 'addMemory' in key method map
---

Here is the excerpt from Application.resources:
---
button.respondent.add.memory = continue to protective order
---
Here is the excerpt from struts-config.xml:
---
 

 
---
My RespondentFormAction class extends the LookupDispatchAction class and 
has the addMemory method:

---
public ActionForward addMemory(ActionMapping mapping, ActionForm 
form, HttpServletRequest request, HttpServletResponse response) throws 
Exception { ... }
---

I also populate the map as such:
---
protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("button.pp.add", "add");
map.put("button.respondent.add.memory", "addMemory");
return map;
}
---
Funny thing is is that I have other LookupDispatchActions working 
correctly in other places.  I don't know what I'm overlooking and doing 
differently with this one.

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


Any way to retrieve the index of html:select?

2005-05-06 Thread Randy Kennedy
I was wondering if there is any way to retrieve the selection index of 
the  during the action.  The value that I'm storing is the 
coded value for the description that it represents (e.g. 1 for male, 2 
for female).  Instead of taking the value and hitting the database, I 
would like to take the selection index and use that to pull the 
information out of a List that is stored as a session variable.

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


Setting focus on invalid form submission

2005-05-02 Thread Randy Kennedy
Relatively new to the list, so I apologize if this has already been 
submitted.

I am wondering if there is a way to set the focus after a form has been 
validated through Struts and deemed invalid?  Currently, focus always 
goes to the first form element.  Is there not a way to make this go to 
the first INVALID form element?

Thanks for any help.
--
Randy Kennedy
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]