File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Cannot retrieve ID from GET method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Cannot retrieve ID from GET method" Watch "Cannot retrieve ID from GET method" New topic
Author

Cannot retrieve ID from GET method

Fandy Akhmad
Ranch Hand

Joined: Nov 26, 2011
Posts: 32

Dear, master Java

I try to make CRUD Application using Struts2 , but there is problem while i edit data.
Problem is : Id cannot retrieve, its return 0(zero)

I get Id using this code (velocity) :


Then I try to ouput in console :


But Ouput : 0

This is my entity [Pegawai.java] :
http://pastebin.com/vwKaG86H

This my action [View.java]
http://pastebin.com/GZQT7fwd

And the last one my view, [view.vm]
http://pastebin.com/vhWxehjX

Anyone, please help me,

Thanks before..
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Ha, interesting

1. You get 0 since your ID is of type int. May be you are not setting the value of Id. Where are you setting the value for this?
2. I guess "./view.action?id=$emp.id" would be taken as a single entity and does not evaluate the value of $emp.id. I didnt work in struts 2 and hence do not know exact conventions/syntax maybe try single quotes like "...?id='$emp.is'" - again this might work or may not, not sure.
3. ------------not at all important, but your code is very much vulnerable to SQL injection



Have Fun with Java
little,little.. little by little makes a lot..
 
wood burning stoves
 
subject: Cannot retrieve ID from GET method
 
Similar Threads
JTable doesn't show new model after adding new row
Problem with a Managed Bean
Using String() method to initialize variable
JAXB Saving and loading a generic List of type T to/from XML
file cannot be resolved to a type