-
1. Re: Is It Possible To Get Method Parameter using Weld?
cjalmeida Oct 4, 2010 7:26 PM (in response to xsalefter.xsalefter.yahoo.com)This is usually not possible in a portable way, since parameter names are usually stripped when compiling into bytecode. It's possible if you use some JavaAssist + set debug flags when compiling.
To get where you want, maybe you could use a convention where you could use the method name for the auto-binding. Such as
buttonCreate_OnClick
like good ol' VB6? -
2. Re: Is It Possible To Get Method Parameter using Weld?
swd847 Oct 4, 2010 10:29 PM (in response to xsalefter.xsalefter.yahoo.com)The usual solution to this particular problem is to put the name into a parameter annotation, in this case you could add a field to the OnClick annotation or create a new one specially:
public void onClickButtonCreate(@OnClick("buttonCreate") JButton buttonCreate, @UI PersonInsertUI personInsertUI) { personInsertUI.setVisible(true); }
-
3. Re: Is It Possible To Get Method Parameter using Weld?
xsalefter.xsalefter.yahoo.com Oct 5, 2010 9:32 AM (in response to xsalefter.xsalefter.yahoo.com)Hi Stuart. I have
proposed
your way on this post , but Gavin tell me that it is untypesafe. So I choose the second approach (my forum post). Hope it's more typesafe.To get where you want, maybe you could use a convention where you could use the method name for the auto-binding. Such as buttonCreate_OnClick like good ol' VB6?
Hi Almeida.. I personally will choose
@OnClick("buttonCreate")
than
buttonCreate_OnClick
It's limit developer freedom, i think.
However Stuart, can Weld provide this feature, so developer don't need to use javaassist / asm manually?
-
4. Re: Is It Possible To Get Method Parameter using Weld?
swd847 Oct 5, 2010 5:24 PM (in response to xsalefter.xsalefter.yahoo.com)
xsa lefter wrote on Oct 05, 2010 09:32:
However Stuart, can Weld provide this feature, so developer don't need to use javaassist / asm manually?No. There are a few problems with it:
- There is no guarantee that the compiler actually generated the appropriate attribute in the bytecode (can't remember what it is called of the top of my head).
- In some environments with funny classloading it is not necessarily possible to read the bytecode of loaded classes directly (I know we have had problems using javassist in google app engine in the past).