jsf - Dynamic bean properties for EL by implenting java.util.Map#get -


I have a @session squid bean which I would like to use as a map so that I can use my properties EL Can I do this by implementing java.util.Map to implement the view object (object o) with my application logic. Throwing an unsupported exception to all other accelerated map methods.

  @ session: SCOXED @ Nominated Public Segment MyBean Apply Map & lt; String, string & gt; {@ Override Public String (object's) {// Application logic here} @ Override Public Boolean (object's) included (new unsupported operation expansion); } / / All other map methods are included as overrides. Key}  

Properties are read only and I only need to use the method obtained from my code, Is not it safe to implement?

Is there a better way of defining dynamic properties for EL in the bean? It would be better to store this map as a session attribute, so you should get a @ sessioncached

Beans need not be made and it can be accessed through the language of expression without problems.
  Public Zero Dictathed Cutet () {// To declare the variable as myBean for compatibility with your current code map & lt; String, Object & gt; MyBean = new Hashmop & lt; String, Object & gt; (); // fill my bean ... // ... in my Bean session FacesContext.getCurrentInstance () .getExternalContext () .getSession (wrong) .setAttribute ("myBean", myBean); }  

You can enter EL directly:

  $ {myBean ['key']}  

From the comments:

The issue is that my bean is not actually a map in the method of receiving logic based on the key I get Required I (...) In my case the business logic is not expensive in the recipient.

It looks like you will need to implement the Map interface in any way. Instead, modify the wheel to throw expanded unsupported operation exposure from the class implementing all methods like hashmap or LinkedHashMap , or To mark the methods or a class that implements the map but it does not apply at all, like, and leaves other methods blank:

 < Code> @named @ session-scripts public category MyBean AbstractMap & lt; String, Object & gt; {@Override Get Public Objects (String Key) {// Add Your Logic Here ...} @ Override Public Zero Set (String Key, Object Values) {// Nothing ...} // Other Unnecessary Methods same. ..}  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -