You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Sachin Kumar <sk...@novell.com> on 2003/06/28 09:00:58 UTC
Help needed
Hi,
I have to send data from a vm page to the server side where I could
process it and save it into database.
For example:
Suppose I have a Effort Entry form, where I have
Task Name Effort Spent
T1 __________ a text field
T2 __________
The number of tasks is known dynamically, from database. I need to fill
the effort for the listed tasks and then call SAVE on it.
Now my action method doInsert() is called which takes this data and
save these multiple records in a TASK table in database.
Here if you see, if I have 'N' tasks , then I have to create N
varialbes which I am doing using velocityCount (like
task$velocityCount). So the problem is that again on server side to get
the data I need to generate the same variable names. I know this is not
a good way, but would like to hear from any of you guys who have better
ideas /solution to do the same.
Thanks in advance.
Sachin
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Help needed
Posted by Michael Mainguy <ma...@mich.com>.
My solution to this sort of thing is use multiple items with a surrogate
key (if you want)...
i.e.
<input type="hidden" name="taskid" value="1"/>
$taskName
<input type="text" name="effort" value="0"/>
<input type="hidden" name="taskid" value="1"/>
$taskName
<input type="text" name="effort" value="0"/>
<input type="hidden" name="taskid" value="2"/>
$taskName
<input type="text" name="effort" value="0"/>
<input type="hidden" name="taskid" value="3"/>
$taskName
<input type="text" name="effort" value="0"/>
<input type="hidden" name="taskid" value="4"/>
$taskName
<input type="text" name="effort" value="0"/>
and so on...
then on the server side you just do a
public void doInsert(RunData data, Context context) throws Exception {
int[] taskids = data.getParameters().getInts("taskid");
int[] efforts = data.getParameters().getInts("effort");
for (int i =0; i < taskids.length; i++) {
...
Do whatever you need to do with taskids[i] and efforts[i]
...
}
}
On Sat, 2003-06-28 at 03:00, Sachin Kumar wrote:
> Hi,
>
> I have to send data from a vm page to the server side where I could
> process it and save it into database.
> For example:
> Suppose I have a Effort Entry form, where I have
> Task Name Effort Spent
> T1 __________ a text field
> T2 __________
>
> The number of tasks is known dynamically, from database. I need to fill
> the effort for the listed tasks and then call SAVE on it.
> Now my action method doInsert() is called which takes this data and
> save these multiple records in a TASK table in database.
> Here if you see, if I have 'N' tasks , then I have to create N
> varialbes which I am doing using velocityCount (like
> task$velocityCount). So the problem is that again on server side to get
> the data I need to generate the same variable names. I know this is not
> a good way, but would like to hear from any of you guys who have better
> ideas /solution to do the same.
>
> Thanks in advance.
>
> Sachin
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
--
Michael Mainguy
(248)935-8507
mainguym@mich.com
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org