There's one big flaw with your proposal: it's not really “transparent”; the code “using” it has to know it's there (i.e. it's not AOP as you described it), because some @UiField could be 'null' or not visible (depending on actual implementation).I believe applying such a rule as “this widget might not be created at all” globally might solve some use cases, but opens other issues: e.g. how do I layout my screen depending on what's actually visible?
Another rather big issue with the proposal is that it only applies to UiBinder. How do you solve the same problem when you're not using UiBinder? How about navigation in your app? (when you use History.newItem, or Places, or Activities, or a third-party solution such as GWTP – OK, GWTP has its own “security” feature)
There's also the question of “what to do?” when a precondition is not met? Should the widget not be created at all? should it be hidden? should it matter to the user of the API? What if I'd prefer that my button be visible but disabled?
Last, but not least, having such an API in GWT for widgets but nothing related to communications (GWT-RPC, RequestFactory) is likely to lead to applications that aren't actually secure, because developers have a false sense of security provided by the API that just doesn't create their widgets.
So, my advice, as already given elsewhere, is: build what meets your immediate need (either from scratch, or on top of UiBinder, or as a fork of UiBinder), iterate on the API until you're satisfied, then (possibly) iterate again to try to solve other use-cases.
If you forked UiBinder, try to come up with an extension API (preferably not extending/reusing the generator, but rather providing extensions to it, similar to how ResourceGenerator and CustomFieldSerializer allow modifying the generator's behavior) on which you could build your security-oriented feature and try to upstream the patch.When and if your library got enough traction, then you can propose it's made part of GWT core (and if the Steering Committee agrees, then you would probably become its maintainer then, responsible for reviewing patches et al.)
Also, more technically-speaking, if you can build it as an annotation processor (or possibly another kind of pre-processor) rather than a GWT generator, it could be even better.
There's one big flaw with your proposal: it's not really “transparent”; the code “using” it has to know it's there (i.e. it's not AOP as you described it), because some @UiField could be 'null' or not visible (depending on actual implementation).I believe applying such a rule as “this widget might not be created at all” globally might solve some use cases, but opens other issues: e.g. how do I layout my screen depending on what's actually visible?
There's one big flaw with your proposal: it's not really “transparent”; the code “using” it has to know it's there (i.e. it's not AOP as you described it), because some @UiField could be 'null' or not visible (depending on actual implementation).I believe applying such a rule as “this widget might not be created at all” globally might solve some use cases, but opens other issues: e.g. how do I layout my screen depending on what's actually visible?As I mentioned it in the user group discussion: the fact that a field is not created is a good thing since it permits to the user to early detect he is trying to deal with a field that will not exist in certain conditions (I called that a runtime-compiler: since it checks if there are potential bugs at runtime). Furthermore, the field is not obliged ot be null, it can be parametrized with a factory strategy (create non visible fields or create them null): in any case it will be less hardcoded than the actual solution that does raw GWT.create() without any possible choice.
By the way, how do you justify that you prefer a hardcoded solution to an extensible one???We both know it's not AOP, it can't be since there's no proxying mechanism. But it works as if it was: you can intercept the widget creation and do decide if you want the default process to be executed or/and yours.
- UiBinder is totally declarative - if it had the feature to wire in logical statements, we should equally have loop and conditional constructs.
- Not everyone uses UiBinder, not everything can be done with UiBinder
- I don’t see a full proposal anywhere
- isAllowed and isVisible
I created an issue where I specify more clearly the change proposal: https://code.google.com/p/google-web-toolkit/issues/detail?id=8735
I'm just unable to push the code for review
Tue May 27 12:28:27 2014
Pushing to https://gwt.googlesource.com/gwt
POST git-receive-pack (24854 bytes)
remote: Resolving deltas: 2% (1/34)
remote: Resolving deltas: 5% (2/34)
remote: Resolving deltas: 8% (3/34)
remote: Resolving deltas: 11% (4/34)
remote: Resolving deltas: 14% (5/34)
remote: Resolving deltas: 17% (6/34)
remote: Resolving deltas: 20% (7/34)
remote: Resolving deltas: 23% (8/34)
remote: Resolving deltas: 26% (9/34)
remote: Resolving deltas: 29% (10/34)
remote: Resolving deltas: 32% (11/34)
remote: Resolving deltas: 35% (12/34)
remote: Resolving deltas: 38% (13/34)
remote: Resolving deltas: 41% (14/34)
remote: Resolving deltas: 44% (15/34)
remote: Resolving deltas: 47% (16/34)
remote: Resolving deltas: 50% (17/34)
remote: Resolving deltas: 52% (18/34)
remote: Resolving deltas: 55% (19/34)
remote: Resolving deltas: 58% (20/34)
remote: Resolving deltas: 61% (21/34)
remote: Resolving deltas: 64% (22/34)
remote: Resolving deltas: 67% (23/34)
remote: Resolving deltas: 70% (24/34)
remote: Resolving deltas: 73% (25/34)
remote: Resolving deltas: 76% (26/34)
remote: Resolving deltas: 79% (27/34)
remote: Resolving deltas: 82% (28/34)
remote: Resolving deltas: 85% (29/34)
remote: Resolving deltas: 88% (30/34)
remote: Resolving deltas: 91% (31/34)
remote: Resolving deltas: 94% (32/34)
remote: Resolving deltas: 97% (33/34)
remote: Resolving deltas: 100% (34/34)
remote: Resolving deltas: 100% (34/34)
remote:
remote: Processing changes: refs: 1
remote: Processing changes: refs: 1, done
To https://gwt.googlesource.com/gwt
! [remote rejected] uibinderfactory -> master (prohibited by Gerrit)