• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Code for replacing 'get' and 'set' method

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic