struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paweł Wielgus <poulw...@gmail.com>
Subject Re: In struts, How to solve this with Database and jsp?
Date Sun, 04 Oct 2009 21:52:38 GMT
Hi,
below is pseudo code for form representing new row:

< form action="yourInsertAction" >
< input type="text" value="...place row value here " name="rowValue" />
< input type="submit" value="add row" />
< /form >

then in Action:

DB.insertNewRow(myForm.getRowValue());

But i don't understand what You mean by saying that You have created
add and delete function in javascript?
Are You using some ajax framework like jquery or something?

All in all this is very common and simple task,
the only way to upload something to Action is by submitting a form,
and reading it's fields in Action.

Are You aware of Struts workflow looks like?
If not, it will be very hard for You to go further, and if so i
recomend reading about it first.

Best greetings,
Paweł Wielgus.


2009/10/4 kaushal.sharma <kaushalksharma.mtech@gmail.com>:
>
> Hi Pawel,
>
> Thanks for your reply.
>
> but not sure with this.
>
> can you suggest me with some code as i have created to function for add and
> delete a row in javascript, i need to send back the operations done on jsp
> to my asction servlet with the values so that my servlet can updated the
> database.
>
> hope you will have something to provide me.
> if you want to see the code i can provide you that.
>
>
> Please suggest.
>
>
> -Thanks & Regards,
> Kaushal K. Sharma
>
>
>
>
> Paweł Wielgus wrote:
>>
>> Hi Kaushal,
>> You can treat a html form as a representation of a new row in Your
>> table (for example at the bottom of the table),
>> then this form can be submited to an AddRowAction and after inserting
>> this "new row" to a DB redirected back to ListRowsAction.
>> Also you can add link to edit properties of one row on another jsp in
>> every one row (many "edit this row" links),
>> or create one huge form that will use indexed properties to edit all
>> rows in place,
>> keep in mind that the perfect solution is dependant of the situation,
>> so You have to choose how it will be better for Your users.
>>
>> Hope that helps.
>>
>> Best greetings,
>> Paweł Wielgus.
>>
>>
>>
>>
>> 2009/10/4 kaushal.sharma <kaushalksharma.mtech@gmail.com>:
>>>
>>> Hi Tommy,
>>>
>>> I know the fundamental of java, but quite new to struts.
>>>
>>> i know my action is getting the data from the database and populating the
>>> jsp tabular form through a bean and same at reverse.
>>>
>>> but my query is...
>>>
>>> how to add a row/ delete a row /save complete form to/from my database
>>> through a javascript function
>>>
>>> i tried it but just got stuck.
>>>
>>> if you need i can provide you my code. Please help me with some code
>>> suggestion. :confused:
>>>
>>>
>>> -Thanks & Regards,
>>> Kaushal K. Sharma
>>>
>>>
>>>
>>>
>>> Tommy Pham wrote:
>>>>
>>>> ---- Original Message ----
>>>>> From: kaushal.sharma <kaushalksharma.mtech@gmail.com>
>>>>> To: user@struts.apache.org
>>>>> Sent: Sun, October 4, 2009 12:59:57 PM
>>>>> Subject: In struts, How to solve this with Database and jsp?
>>>>>
>>>>>
>>>>> Hi All,
>>>>>
>>>>> i am new to struts and i have a problem to store the values to my
>>>>> database
>>>>> and retrieve the values to my jsp, hope you people can solve this ....
>>>>> :confused:
>>>>>
>>>>> i am getting the records from database to my jsp, in a tabular format
>>>>> as
>>>>> 1
>>>>> Record in 1 ROW.
>>>>> for ex.
>>>>>
>>>>> >> First ROW Record       >>   1. selectbox     2.
textfield     3.
>>>>> checkbox
>>>>> >> 4. checkbox     5. textfield     6. checkbox     7. CancelIMAGE
>>>>> >> Second ROW Record   >>   1. selectbox     2. textfield
    3.
>>>>> checkbox
>>>>> >> 4. checkbox     5. textfield     6. checkbox     7. Cancel
IMAGE
>>>>>
>>>>> :working:
>>>>
>>>> If I'm not mistaken, the problem you're facing is not with Struts in
>>>> particular but with understanding the fundamentals of Java.
>>>>
>>>>> Q 1.  How can i get the values for all the fields from the database
and
>>>>> how
>>>>> can i store all of them back to database?
>>>>
>>>> Basic is straight JDBC calls.  More advanced is EJB, persistence (like
>>>> Hibernate), etc.  Before getting into JDBC or more advanced technology,
>>>> strong grasp of basic SQL syntax is required.
>>>>
>>>>> Q 2.  I am not using
>>>> for this tabular form, and i used to Javascript
>>>>> functions on my JSP page,
>>>>>         ONE for "DELETE ROW" and
>>>>>         SECOND for "ADD NEW ROW"
>>>>>         Both functions are working fine on jsp but not sure how these
>>>>> functions will delete and add the row from / to database?
>>>>>
>>>>
>>>> See above.  Full understanding of database access layer will answer this
>>>> question for you.
>>>>
>>>> Regards,
>>>> Tommy
>>>>
>>>>> FYI
>>>>>
>>>>>       function addRow(tableID)
>>>>>             {
>>>>>                 var table = document.getElementById(tableID);
>>>>>                          var rowCount = table.rows.length;
>>>>>                 var row = table.insertRow(rowCount);
>>>>>                 var colCount = table.rows[0].cells.length;
>>>>>
>>>>>                 alert(table.rows.length - 1);          
      //
>>>>> deleting
>>>>> the
>>>>> first row
>>>>> in counter for table index...
>>>>>
>>>>>                 for(var i=0; i
>>>>>                 {
>>>>>                     var newcell = row.insertCell(i);
>>>>>
>>>>>                     newcell.innerHTML =
>>>>> table.rows[1].cells[i].innerHTML;
>>>>>
>>>>>                 }
>>>>>             }
>>>>>
>>>>>
>>>>>             function deleteRow(target)
>>>>>             {
>>>>>                 do {
>>>>>                     if ( target.nodeName.toUpperCase() == 'TR'
) {
>>>>>                         target.parentNode.removeChild(target);
>>>>>                         break;
>>>>>                     }
>>>>>                     alert(target);
>>>>>
>>>>>                 } while ( target = target.parentNode );
>>>>>
>>>>>             }
>>>>>
>>>>>
>>>>>
>>>>> hope you people don't mind to provide me the code and helpful tips, as
>>>>> i
>>>>> am
>>>>> new to struts i feel you people will help me this way ASAP.  :-)
>>>>>
>>>>> One more thing, please provide me some example tutorials for struts,
so
>>>>> that
>>>>> i'll understand,
>>>>>
>>>>>
>>>>> -Thanks in Advance.
>>>>> Kaushal K. Sharma
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/In-struts%2C-How-to-solve-this-with-Database-and-jsp--tp25741588p25741588.html
>>>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/In-struts%2C-How-to-solve-this-with-Database-and-jsp--tp25741588p25742053.html
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/In-struts%2C-How-to-solve-this-with-Database-and-jsp--tp25741588p25742324.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message