Re: Accessing property via "Unary Accessor"

"Eric B. Ridge" <[email protected]> Tue, 7 Mar 2006 19:27:21 -0500
Newsgroups gmane.comp.java.webmacro.user
Message-ID <[email protected]>
WebMacro has to be precise in its spelling of properties because it's  
the only way to provide predictable results.

For example, what if your Bean also had:
	gettitle()
	getTitle()
         getTiTle()
	getTITLE()
	gettitlE()
	etc, etc

Which one would you want WebMacro to choose when the template  
designer typed $board.title?

This is somewhat of a hack, but if you want case-insensitive matching  
for property names, don't expose them at all through member  
functions, but instead implement a single get() method:

	public Object get(String proname) {
		return _propmap.get(proname.toLowerCase());
	}

This would allow any of these to return the same value:
	$board.title
	$board.Title
	$board.TITLE
	$board.TitLe
	etc, etc

But really, it's a horrible horrible idea and you shouldn't do it.   
Instead, just get used to WebMacro honoring the case of property  
names as they were defined in your class.  :)

eric


On Mar 7, 2006, at 7:15 PM, Sven Schliesing wrote:

> Hi,
>
> I'm having a class "Board" which has a private property "title".  
> For this property there is also a public getter "getTitle()", so  
> that webmacro can access it via "$board.Title"
>
> Unfortunately this was so uncommon to me, that I tried  
> "$board.title" for nearly two hours now before realizing what I was  
> doing wrong.
>
> What is the reason (I'm pretty sure that there is a good one :) )  
> that the accessor is not (also) trying "getTitle()" when using  
> "$board.title"? The property is "title" and not "Title", so. In  
> general a template designer should not even care about that. He  
> should know what properties the Bean got ("title" in my case) and  
> not how their getters are spelled.
>
>
> Or am I getting something totally wrong? :)
>
> Thanks for your help!
>
> Greetings from snowy Hamburg
>
> Sven
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting  
> language
> that extends applications into web and mobile media. Attend the  
> live webcast
> and join the prime developer group breaking into this new coding  
> territory!
> http://sel.as-us.falkag.net/sel? 
> cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Webmacro-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/webmacro-user



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642