• Post Reply Bookmark Topic Watch Topic
  • New Topic

Updatings in database with JSP,EJB,XSL,XSP on JBoss

 
Andrew Baba
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Im pretty new with JSP. I tried to solve the problem through search option but couldn't find it.
I am currently doing internship and I am having problem with updating data in the database.They work here on jboss. They use JSP, EJB, XSP,XSL and mysql.
I have a table and I would like to send updated data back to database by clicking SUBMIT button. Picture below


I should code this by finding correct id ,using LocalizationDataModel,storing model in the session. Should find correct ID in the database and next update it.
Here how it looks that in mysql



I have already got method savaLocalizationData in EJB, which I am sure is correct



They told me I should work right now with controller.jsp
Here is code and advices in comments for a save localization data, I also added a sample how they display pages in listLoclizationData page



Here is a XSP page for that


Here stylesheet in XSL form




CAN ANYBODY HELP ME WITH THAT ? I am not sure how should start with that in controller.jsp. Any help very appreciate

 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you write the jsp? or are you maintaining somebody else's code?

as there is far to much actual java code in there, that should all be somewhere else.
all your jsp should od is get data from the user, and display data to the user (and pretty pictures). It should be really really dumb.

now I have got that off my chest, i will actually read the code.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew Baba wrote:




Here is code and advices in comments for a save localization data, I also added a sample how they display pages in listLoclizationData page




is this the actual jsp page you want help with?
 
Andrew Baba
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code is mine. I created all of that on my internship. I have already made some changes and saveLocalizationData page is being already updated. Code from controller.jsp is not complete. There are more pages which I havent showed here.
I coded this


Right now the question I have is how to attach saved changes to the correct language in the database. When I display website lets say for a different language it still only making changes for Polish. How do you think ? Im thinking about if statement
 
john wutka
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'If' Sounds fine to me.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you know about forms, and submitting in HTML? As that is what you should be learning and writing.
Then the java should be in the servlet that gets called when the form submits, and the servlet then sets the next page.

I do not know how that fits in with all the framwork code you have to work around.

I would recommend getting a good book, the head first jsp book is good
http://shop.oreilly.com/product/9780596516680.do
 
Andrew Baba
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wendy Gibbons wrote:do you know about forms, and submitting in HTML? As that is what you should be learning and writing.
Then the java should be in the servlet that gets called when the form submits, and the servlet then sets the next page.

I do not know how that fits in with all the framwork code you have to work around.

I would recommend getting a good book, the head first jsp book is good
http://shop.oreilly.com/product/9780596516680.do


I know basics in forms. I use forms through xsl stylesheet if I need it. Thanks for a book recommendation. I have just ordered from amazon. I was lucky I started this internship. I sold myself well on interview. I know that technologies are too deep for me. Right now I have to learn it anyway- it is motivates me. I have only finished introduction to Java so far (college) and started internship with EJB related technologies BOOM ! That's way I created this topic to ask advanced users about help. In the future I will help someone else. This is how it works, isn't ?

Back to the topic. I have created if statement. But If statement is not effiecient because I don't want add each time extra language to the controller.jsp Can somebody show me how to create loop instead?

 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at enums (not enumerations)

here is a good page:
http://docs.oracle.com/javase/1.5.0/docs/guide/language/enums.html

I would make a method in ModelToCheck that took a language and s_TheTranslation, then this code could be inside model to check.

then inside model to check it could use the enum.

here is some psuedo code, because how to get the correct enum from the id is a bit of a learnt trick (it will not compile)


 
Andrew Moko
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wendy Gibbons wrote:Have a look at enums (not enumerations)

here is a good page:
http://docs.oracle.com/javase/1.5.0/docs/guide/language/enums.html

I would make a method in ModelToCheck that took a language and s_TheTranslation, then this code could be inside model to check.

then inside model to check it could use the enum.

here is some psuedo code, because how to get the correct enum from the id is a bit of a learnt trick (it will not compile)




Who uses enums, Wendy ;)

Proper use of generics brings out well-laid out, short understandable code and abstracts complexity. I'd create a generic method on modelToCheck that takes a language type. Inside the method check the language and call the appropriate method/ functions.

 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do, you can either have 20 small classes, or 1 enum each with it's own method

can you show me how you would do it with generics?
 
Andrew Moko
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wendy Gibbons wrote:I do, you can either have 20 small classes, or 1 enum each with it's own method

can you show me how you would do it with generics?


Sure. Here's my two centavos..



This method allows languages to be set dynamically without necessarily modifying the LocalizationDataModel class.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew Moko wrote:
Wendy Gibbons wrote:I do, you can either have 20 small classes, or 1 enum each with it's own method

can you show me how you would do it with generics?


Sure. Here's my two centavos..



This method allows languages to be set dynamically without necessarily modifying the LocalizationDataModel class.


you haven't shown how you get the language class from the ID that is supplied, how you get rid of that big case statement?

 
Andrew Moko
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wendy Gibbons wrote:
Andrew Moko wrote:
Wendy Gibbons wrote:I do, you can either have 20 small classes, or 1 enum each with it's own method

can you show me how you would do it with generics?


Sure. Here's my two centavos..



This method allows languages to be set dynamically without necessarily modifying the LocalizationDataModel class.


you haven't shown how you get the language class from the ID that is supplied, how you get rid of that big case statement?





I'm i missing out something??


 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry a DOH moment, hashmaps DOH.
 
Andrew Moko
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wendy Gibbons wrote:sorry a DOH moment, hashmaps DOH.


LOL

*off for my coffee break TGIF*
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!