Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

null pointer exception in struts2

 
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We all know that the variable name in Action class should be name of the html tag...

I have something like this





The variable names in action class:
private String conceptName;
private String attributeName;
private String addDTList;

I also have get,set methods for these...

On click on submit

When I print the above values its only printing addDTList while the other 2 are null,,,why is that so??


 
Sheriff
Posts: 9643
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us the code of your action and what you are doing in the addRow('vocab','Add') method...
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
code for addRow() method





and here is the action class...





The output on button click is as follows...

--------------------------------------------------------
Inside Vocabulary Action Class
The addVocOk is :-->Ok
saveVocabulary-->null
gotoRuleset-->null
--- it's in addVocabulary !!!
The vals are :--->,,Integer
The npe is :--java.lang.NullPointerException


-------------------------------------------------------




 
Ankit Garg
Sheriff
Posts: 9643
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm clueless what you are trying to do with that method in JS as the dynamic row that you create will be of no use as the page will be posted back. And what's the use of these two lines
 
Ankit Garg
Sheriff
Posts: 9643
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also in your action, is the field public Attribute attribute; initialized anywhere?? The line The vals are :--->,,Integer in your output shows that the values of conceptName and attributeName are empty and not null...
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit,

I want to add rows dynamically and also allow selection of rows on mouse click (delete,modify both UI and DB)...that's what i am trying to do...

yes the page is being posted back and being a tyro am struggling how to avoid it.

I guess I should create objects of concept and attribute there!

Those 2 lines are incorrect...removed!

Any other suggestions and solutions from your side would be of great help...
 
Ankit Garg
Sheriff
Posts: 9643
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to add dynamically on the server without the page posting back, then you'll have to use an AJAX request. To stop postback of the page, either make the OK button a normal button instead of submit button or return false from the addRow method...
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But If I make OK or normal button, it cuts the interaction with action class and nothing happens...only submit would allow interaction with Action class,itsn't it?correct me I f I am wrong.

Also,congrats on that scjp score...I am writing SCJP 6.0 on NOV 8th as it was a bit haste due to some reasons and I have zero preparation...Do you think I can make the cut? I will be starting my preparation today ans some inputs,papers etc would be of great help.Thanks!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's why the previous comment said to use Ajax.
 
Ankit Garg
Sheriff
Posts: 9643
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Pradeep Adibatla wrote:I am writing SCJP 6.0 on NOV 8th as it was a bit haste due to some reasons and I have zero preparation...Do you think I can make the cut? I will be starting my preparation today ans some inputs,papers etc would be of great help.Thanks!


So you are going to rely on 9-10 days of preparation?? That's not good. The SCJP exam is not that easy to crack. Why don't you postpone the exam a bit. Also for further discussion on this, start a new thread in the SCJP Forum...
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my above mentioned JavaScript I want to add rows and do mouseover and out for all the rows I add and then select any row but alas i could do that only with the recent row added...what should be the change? help...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!