Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble with dynamic text field in table  RSS feed

 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table in jsp like this

mon yr atype comm


All are drop down values except comm. comm is a text field. I am able to update and insert all drop down values . But for comm which is a text field is not updating. Anybody can tell how to add a comm text field to the table
mon yr atype comm
[ October 04, 2005: Message edited by: Bear Bibeault ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to post some of your code or spend some more time giving us some details about how it is written.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"lak kal", please read this.
[ October 03, 2005: Message edited by: Bear Bibeault ]
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Bear edit: removed complete JSP file on one line that made it impossible to read]
[ October 04, 2005: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"lak kal",

You and I have a number of things to talk about.

Firstly, as I mentioned before, please use a descriptive subject title. "jsp" is not very informative. I have changed the title of this topic for you to something that describes your problem better.

Secondly, please be sure that any code you post to the forum is well-formatted and is not going to screw up the formatting of the topic as the code that you posted has done. I tried to go in and fix the formatting for you, but it was just too much work. So I have removed the code. Please re-post it with line breaks and proper formatting.

Lastly, you are going to need to change your display name to something that is not so obviously fictitious. Just reversing the letters of one name to make another is a bit too obvious.

The JavaRanch is a great place to come and get help with your Java and JSP code. These tips, suggestions and requirements are to help you make the most of this resource.

thanks,
bear
Forum bartender
[ October 04, 2005: Message edited by: Bear Bibeault ]
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could anyone help me in solving the above problem???
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"lak kal",

My request that you change your display name was not a suggestion.

Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and [b]must not be obviously fictitious[/b} as yours is.

bear
Forum Bartender
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could any one tell me. Is it possible to add text array field in a jsp table which has got only drop down values???
[ October 05, 2005: Message edited by: lakshmi manepally ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a form parameter with the months size in it.


In the servlet (or jsp if that's your form's target), use that variable to determine how many entries you're dealing with, create an array of that size, and then, within a loop, fill the array elements with the parameters.
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I do like this after

[ October 06, 2005: Message edited by: lakshmi manepally ]
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I do in the same way as you said it is updating, but after when I was trying to retrive the same value again I am getting nulls.Why it is happening like that??
 
Tien-Chih Wang
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
you can try to store comment values in Session.

Tien-Chih Wang
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have done like this



It is updating successfully on that page and also going to the database.But when I go to previous page and display this page again it is showing null values. I don't understand what is the problem.
 
Tien-Chih Wang
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
When initializing the comment value, the value should be retrieved from DB rather than request.getParameter().
comment = request.getParameter() only used when doing the FORM udpate.
Hope that helps,

Tien-Chih Wang
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it didn't work. If I update the values it is updating properly, but if go back and try to see the values again, it is showing null values.
 
Makarand Parab
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lakshmi
Can you write step by step scenario what your trying to do. We have seen your code, let me know what exactly your requirement is.

Regards
Makarand Parab
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My requirement is adding a text comment field to this table. If I update the values for comments it updates properly and also going to the database.But if I go back and come to this page and look for the values it is showing null values.
<td class="formField" align ="center"><input type="text" name="comments<%=i%>" value ="<%=comment[i]%>">
[ October 06, 2005: Message edited by: lakshmi manepally ]
 
s penumudi
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lakshmi,

Try to understand reply posted by Tien-Chih Wang.
Tien-Chih Wang made a right point.

After updating values into the database, the request is comepleted.
Hence your request object does not contain comments.

To get these values back from the request object you have to explicitly add these comments to request scope. Else, you have to forward your request to same JSP page from your controller/servlet.

Hope this helps.
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I add explicilty comment to the request scope
 
s penumudi
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From your controller/servlet from where you are navigating back to your JSP page, say

request.setParameter("comment"+i,commentFromDatabase)

Which would make all comments available to the request object.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!