• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can getters/setters be seperated from the ActionSupport class with a bean?

 
E Robb
Ranch Hand
Posts: 111
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to seperate the getters/setters from an ActionSupport class for reuse in other Action Classes. I dont seem to be able to retrieve the values set in the Action class in the view. Im sure I am missing something silly.

Below is a simple example of what I am trying to do. If anyone could point out where I might be going wrong it would be greatly appreciated.

Struts.xml:


TestAction.java:


PersonBean:


View Page (testaction.jsp):



The results are in the screen shot.

Why can I not retrieve "Hello World" that is set in my Action class?
results.jpg
[Thumbnail for results.jpg]
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your action should implement modelDriven interface
http://www.vaannila.com/struts-2/struts-2-example/struts-2-model-driven-action-example-1.html refer this example
 
E Robb
Ranch Hand
Posts: 111
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MoHaNa RaO wrote:Your action should implement modelDriven interface
http://www.vaannila.com/struts-2/struts-2-example/struts-2-model-driven-action-example-1.html refer this example


This worked but now in my view page both <s:property value="FirstName" /> AND <s:property value="firstName" /> work to retrieve the value "Hello World" Shouldnt only "firstName" retrieve the value? I dont understand I thought Java was case sensitive.

Here is the altered code from my edited example. Can anyone tell me wy both firstName and FirstName retrieve the value?

Getters/Setters Model:



The Action:


The view:



Both property values return "Hello World" Shouldnt one or the other return the value but not both?

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic