Re: [Webwork-user] Calling methods from views
Brought to you by:
baldree,
rickardoberg
From: Rickard <ri...@jb...> - 2000-11-30 07:27:33
|
Hey "Maurice C . Parker" wrote: > Yesterday during my work on porting Jive to a portal style framework I ran into an issue where there was data that I needed pull into one of my views from an existing Jive object. > > The problem is that the data wasn't accessible via an accessor, but only by calling a method. This is what I needed to call: > > public String getProperty(String s); > > Would the ability to call methods from within views break Webworks pull model or would it be undesireable for view programmers to call methods? > > Thoughts? This is not directly supported, but there is a workaround. The property names, or the subparts of them anyway, can refer to three things: * getX() methods * If current result is a java.util.Map, then call get(X) instead * If current result is a java.util.ResourceBundle, then call getObject(X) instead So, it would be possible to do what you want right now by hiding it behind a Map. public Map getProperties() { return new AbstractMap() { public Set entrySet() { ... get properties into a Set and return it } } } Then you can refer to it by doing "properties:foo", which will be equivalent to getProperties().get("foo"). If you do this, please send me the complete code (if that's ok I mean) so I can add this as an example. As you're probably beginning to see the magic of WebWork is not in it's API, but in the design and implementation patterns that one can use. This is one such important pattern. regards, Rickard -- Rickard Öberg Email: ri...@jb... |