Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Code for replacing 'get' and 'set' method  RSS feed

 
Alejandro Gg
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was a struts programmer but now i am a jsf programmer :-)
I was able to do the following with struts but no with jsf...

The following code in struts allowed me to have no 'get' and 'set' method in the javabean for a property (for example, the property 'name'):



In the jsp, using the corresponding label to retrieve the 'name' property, returned value 'John'.

Is there something equivalent in JSF?

why would i not want to use a getter and a setter?

ok, i am integrating struts2 and icefaces in a application.
I want to continue using the Struts controller layer to redirect ICEFaces pages.
In struts.xml I describe the method of the class for the pass before going to my ICEFaces page:



In the method 'myMethod' i called to the 'setName' method for assign a value to the property 'name'.
The trace of the program in fact goes by that method and redirect to the ICEFaces page. But in this page, to try to recover the value of this property, retrieve a null value.
I guess it's because a ICEFaces page can not access the stack of struts.
So I want to use ICEfaces-JSF api to programmatically set the value of property in the method 'myMethod', pass the information on a framework to the other.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alejandro Gg wrote:

Why would you set the value stack back into the context? That already *is* the value stack.

You'd need to replace however JSF does its EL value lookup with something that's S2/valueStack aware, like how S2 ties in to the normal JSP EL evaluator. See org.apache.struts2.dispatcher.StrutsRequestWrapper class; I'd imagine you could implement the same type of functionality (with the caveat that I remain blissfully ignorant of JSF).
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSF and Struts both manage their Control aspect using a Servlet. However, the servlet that creates the Struts contexts is not the same servlet that creates the JSF contexts. Neither context exists exists except for the actual period of time that the corresponding servlet is processing a Struts or JSF HTTP URL Request, so you can't refer to both in the same request process.

One of the primary distinctions made between Struts and JSF was that JSF should be able to operate using POJOs, instead of the older, less flexible approach of requiring specialized base classes and interfaces. Also that IoC injection was a key characteristic. The "ideal" JSF backing bean, in fact, would have no "javax.faces" imports at all - it would be 100% generic POJO. In actuality, you do often end up importing JSF model classes, but anything beyond that is suspect.

All of which means that to rebrand a Struts "form bean" for JSF means that you should consider subclassing the bean with true POJO set/get methods. IDE's such as Eclipse can automatically generate the setter and getter methods, so you may be able to eliminate most of the grunt work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!