You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kavita Mehta <ka...@hsc.com> on 2006/06/21 11:38:47 UTC
how to catch unchecked checkbox values
hi,
i am trying to recieve the status of all checkboxes in my JSP file using
form bean . I am using <html:multibox> tag in my JSP . Can anybdy
suggest me how to get the status of all checkboxes .
presently, the form bean just returns me the selected checkbox's value
array ..
Thanks
Kavita
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts Design question
Posted by Scott Van Wart <sc...@indosoft.ca>.
Monkeyden wrote:
> If your implementation is similar to what Scott has mentioned (i.e.
> different operations on the same type of object), then I consider this a
> classic example of a DispatchAction, where type of business entity
> doesn't
> change...just the selected operation on the business entity, thus it
> makes
> sense to have it in the same action.
So I'm trying to figure this out myself. I don't actually have multiple
buttons in a single form, but I'd like to know the solution to this if I
run across it in the future... so here's an example:
<form-bean name="myForm" class="mypkg.MyForm" />
<action path="/myAction" type="mypkg.MyAction" name="myForm"
scope="request" validate="false" parameter="action">
<forward ..... />
</action>
OK and then here's my form:
<html:form action="/myForm">
<input type="submit" name="action" value="Create">
<input type="submit" name="action" value="Update">
</html:form>
Now... two things:
- I used HTML because I can't find a way to get Struts to let me name
the buttons with <html:submit>.
- When the form is submitted, let's say the user clicked the "Create"
button. The action will end up with action=Create, which will hit my
DispatchAction method's Create method.
Is this the right way of doing things? It seems kind of weird, because
now you can't do internationalization (buttons always have to be the
same), and you're pretty restricted with what you can name your buttons
and call your DispatchAction's methods.
Ideas?
- Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts Design question
Posted by Monkeyden <mo...@gmail.com>.
If your implementation is similar to what Scott has mentioned (i.e.
different operations on the same type of object), then I consider this a
classic example of a DispatchAction, where type of business entity doesn't
change...just the selected operation on the business entity, thus it makes
sense to have it in the same action.
On 6/21/06, Scott Van Wart <sc...@indosoft.ca> wrote:
>
> Kavita Mehta wrote:
> >
> > Hi,
> > I have a form which has 3 submit buttons .
> > which is a gud ides ...
> > 1) having seperate 3 action classes for each
> > 2) having a single action class which manages the submit action based
> > on the button which has called this action class.
> It's up to you ;). I typically divide things into multiple actions (and
> possibly forms) when the form data is different. So, if I had a
> record-editing page where you can:
> 1) Update the record you're currently editing.
> 2) Create a new record from the data you've entered.
> 3) Delete the record you're currently editing.
>
> I'd have 2 actions, and 1 form:
> /saveRecord (recordForm) -> SaveRecordAction.execute
> /deleteRecord (recordForm -- only uses the record key) ->
> DeleteRecordAction.execute
>
> You can inspect the button value returned to determine the button
> clicked in a single form.
>
> Have fun,
> Scott
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Struts Design question
Posted by Scott Van Wart <sc...@indosoft.ca>.
Kavita Mehta wrote:
>
> Hi,
> I have a form which has 3 submit buttons .
> which is a gud ides ...
> 1) having seperate 3 action classes for each
> 2) having a single action class which manages the submit action based
> on the button which has called this action class.
It's up to you ;). I typically divide things into multiple actions (and
possibly forms) when the form data is different. So, if I had a
record-editing page where you can:
1) Update the record you're currently editing.
2) Create a new record from the data you've entered.
3) Delete the record you're currently editing.
I'd have 2 actions, and 1 form:
/saveRecord (recordForm) -> SaveRecordAction.execute
/deleteRecord (recordForm -- only uses the record key) ->
DeleteRecordAction.execute
You can inspect the button value returned to determine the button
clicked in a single form.
Have fun,
Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Struts Design question
Posted by Kavita Mehta <ka...@hsc.com>.
Hi,
I have a form which has 3 submit buttons .
which is a gud ides ...
1) having seperate 3 action classes for each
2) having a single action class which manages the submit action based on
the button which has called this action class.
Thanks,
Kavita
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: how to catch unchecked checkbox values
Posted by Scott Van Wart <sc...@indosoft.ca>.
Kavita Mehta wrote:
> i am trying to recieve the status of all checkboxes in my JSP file
> using form bean . I am using <html:multibox> tag in my JSP . Can
> anybdy suggest me how to get the status of all checkboxes .
> presently, the form bean just returns me the selected checkbox's value
> array ..
That's how checkboxes work in raw HTML and form submission, not just
Struts. If you want a list of unchecked values, you can "assume" it
when you get the list of checked values back. So you send out
checkboxes A, B, C, D and E. If only A and B come back, you can assume
that C, D and E were unchecked. Since you drew the checkboxes
initially, it stands to reason you can conjure up the whole set when the
form is submitted.
- Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: how to download a file
Posted by Niall Pemberton <ni...@gmail.com>.
http://wiki.apache.org/struts/StrutsFileDownload
Niall
On 6/22/06, Ed Griebel <ed...@gmail.com> wrote:
> Take a look at org.apache.struts.actions.DownloadAction, I created an
> action that extended it (and implemented the internal StreamInfo) and
> was able to create an action that downloaded a PDF doc in less than an
> hour.
>
> For creating a new file to stream, one approach is to create the temp
> file using (untested, of course):
> File dir = new
> File(request.getSession().getServletContext().getRealPath("."));
> File tmp = File.createTempFile("web",null,dir);
> tmp.deleteOnExit();
> You may not have rights to write to the web server's root directory,
> you might be able to get away with "File tmp =
> File.createTempFile("web", null);"
> Store the data to this temp file, passing the file as a stream in the
> aformentioned StreamInfo object. To eliminate creating the temp file,
> stream the file directly without having an intermediate file.
>
> -ed
>
> On 6/22/06, Kavita Mehta <ka...@hsc.com> wrote:
> > my requirement is to save some lines on the server in a file and then
> > download it to the client's PC . can anybdy suggest how to go abt it ....
> > thanks
> > Kavita
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: how to download a file
Posted by Ed Griebel <ed...@gmail.com>.
Take a look at org.apache.struts.actions.DownloadAction, I created an
action that extended it (and implemented the internal StreamInfo) and
was able to create an action that downloaded a PDF doc in less than an
hour.
For creating a new file to stream, one approach is to create the temp
file using (untested, of course):
File dir = new
File(request.getSession().getServletContext().getRealPath("."));
File tmp = File.createTempFile("web",null,dir);
tmp.deleteOnExit();
You may not have rights to write to the web server's root directory,
you might be able to get away with "File tmp =
File.createTempFile("web", null);"
Store the data to this temp file, passing the file as a stream in the
aformentioned StreamInfo object. To eliminate creating the temp file,
stream the file directly without having an intermediate file.
-ed
On 6/22/06, Kavita Mehta <ka...@hsc.com> wrote:
> my requirement is to save some lines on the server in a file and then
> download it to the client's PC . can anybdy suggest how to go abt it ....
> thanks
> Kavita
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
how to download a file
Posted by Kavita Mehta <ka...@hsc.com>.
my requirement is to save some lines on the server in a file and then
download it to the client's PC . can anybdy suggest how to go abt it ....
thanks
Kavita
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org