Its better that this is posted to the list as well, after all its a good question and hopefully an adequate answer.

<script language="javascript" type="text/javascript">
<!--
function lookup(form) {
        form.elements['action'].value = "lookup";
        form.submit();
}
//-->
</script>

<html:form action="/process.do">


<html:select onchange="lookup(this.form)"> ... </html:select>


<input type="hidden" name="action" value="submit">


<html:submit />

</html:form>

//struts config

<action page="/process.do" type="com.sparrow.struts.MyAction" name="myForm" redirect="false" parameter=""action" />


The only thing you'd have to watch would be if the client didn't support javascript then you'd lose lookup, this would make a case for having action as a form bean property and have some relevantly named form elements in noscript tags. If lookup isn't mission critical then i guess you could let this slide.




On Friday, July 11, 2003, at 08:44 PM, Shyam A wrote:

Mark,
 
Thanks for your mail. I understand that DispatchAction class includes multiple execute methods for different actions. However, I still have some doubts.
 
You mentioned using <html:link> tags in JSP:
 
<html:link page="/processForm.do?action=lookup">


<html:link page="/processForm.do?action=submit">
Are these used instead of using "Submit" buttons ?
i.e use <html:button> and <html: link> in conjunction instead of <html:submit property="action" value="Submit"/> ?  Can <html:link> be used for a drop- down?
 
I guess my problem is still unresolved. As I mentioned in my earlier mail, I have a drop-down associated with an ActionForm property "crn" > .
<html:select property="crn">
       <html:option value="None" selected>None</html:option>      
       </html:select> 
      
I would like to trigger an action called "Lookup" when the drop-down is clicked .i.e, associate the clicking of the drop-down with the "action" property of the ActionForm class. I don't know how to set the "action" property of the ActionForm class  when the drop-down is selected, based on which appropriate method of the DispatchAction class would be executed.
 
Any help would be greatly appreciated.
 
Thanks,
Shyam
 
 



Mark Lowe <[EMAIL PROTECTED]> wrote: check out dispatch actions..

you can have multiple execute methods with dispatch action ...

Your Action class extends DispatchAction instead of action (check the
docs)

public final ActionForward submit(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)

throws Exception {
...
}

public final ActionForward lookup(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)

throws Exception {
...
}

in struts config the parameter attibute need to know the name of the
parameter your about to send, the value of which is your execute method
name..


scope="request" parameter="action"> ...

and then in jsp






HTH Mark



On Friday, July 11, 2003, at 08:00 PM, Shyam A wrote:


> James,
>
> Thanks for your mail. I guess I need to elaborate a little bit. My
> HTML form can be submitted in 2ways.
> 1. Clicking the "Submit" button.
> 2. Clicking the drop-down
>
> Clicking the drop-down triggers a different action than clicking the
> "Submit" button.
> Selecting a value in the drop-down would submit the form and populate
> some of the other fields in the form. This is done before the "Submit"
> button is clicked. So, I need to distinguish the action of clicking
> the drop-down from clicking the "Submit" button and I called it
> "Lookup".
>
> Both actions would be identified with a single property in the
> ActionForm class - action.
>
> eg:
>
>
> I would like to set this "action" property value to "Lookup" on
> clicking the drop-down using Javascript. I guess a hidden field would
> not serve the purpose as I already have "action" property defined for
> the Submit button.
>
> Look forward to your help/suggestions.
>
> Thanks,
> Shyam
>
> James Mitchell wrote:
>
> You will need to create a hidden field named "action", with a value of
> "Lookup":
>
>
>
> My question to you is....why "Lookup"? What does that have to do with
> your
> form?
>
>
> Here's a sample:
>
>
> function submitForm(form) {
> form.action.value="Lookup";
> form.submit();
> return true;
> }
>
>
>
> [input]
> Test Test2
>
>
>
> On Friday 11 July 2003 14:15, Shyam A wrote:
>> Hi,
>>
>> I have an HTML form with Submit and Cancel buttons, and a drop down
>> list,
>> which when clicked submits the form. I use Javascript to submit the
>> form
>> when the dropdown list is clicked. I have a property called "action"
>> defined in my ActionForm class that identifies the Submit and Cancel
>> buttons in the HTML form. When the drop-down is clicked, I would like
>> to
>> set the value of this "action" property to "Lookup".
>>
>> My Javascript function is given below:
>>
>> ################
>>
>>
>> function submitForm(form)
>> {
>> form.action.value="Lookup";
>> form.submit();
>> return true;
>> }
>> #################
>>
>> and I invoke this function in my HTML form as shown below:
>>
>> #########################
>>
>> Test
>>
>> ###########################
>>
>> But, the value of the property "action" is not set to "Lookup".
>>
>> Any help would be greatly appreciated.
>>
>> Thanks,
>> Shyam
>>
>>
>> ---------------------------------
>> Do you Yahoo!?
>> SBC Yahoo! DSL - Now only $29.95 per month!
>
> --
> James Mitchell
> Software Developer/Struts Evangelist
> http://www.struts-atlanta.org
> 678-910-8017
> AIM:jmitchtx
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> ---------------------------------
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!



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



<image.tiff>

Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month!


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



Reply via email to