-
Notifications
You must be signed in to change notification settings - Fork 86
Add support for add-list-attribute to render expressions #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: TILES_3_0_X
Are you sure you want to change the base?
Add support for add-list-attribute to render expressions #5
Conversation
- This will certainly need review as the current implementation breaks current behavior with relation to attributes from list attributes being exposed to the view, while simple attributes are not. - This implementation maps everything to the objects represented type where possible, though due to current requirements elements must remain to be an attribute wrapping the value. - Attribute#getExpression is evaluated and set against a cloned version of Attribute#setValue.
|
can you take commit be97c75 out of the pull request please. |
|
Will do. You can cherry-pick commit brettryan@41759e8 if it's easier, I think I'll have to create a separate pull request though Github doesn't give me the option when I specify a commit range. I'll see what I can' see and let you know. |
I'm reviewing just the individual commits for now, so i'm not waiting on you to pull out that first commit. But it'll need to be done before we accept+push any final patch. I agree that github isn't the best for such things. I find it's easier to keep github branches as atomic as possible. I also don't have any problem with your third commit here being folded into the second, just include the NPE as well in the commit msg. (At the end of the day we'll be accepting and pushing just one patch so to work with just one commit message makes sense already). |
|
No prob, thanks. I've never had to rebase before, just trying to squash my commit messages and not having the best of luck, but, I'm tired and unwell :) I'll see what I can do throughout the week. |
Take it easy and no hurry. |
|
|
Well, I think we should at least have a test case for that. See this commit cc11955 as an example. The tests can be run with As for the incompatibility... well it seems a bit larger than exposed here. If people are using insert-attribute like our test case, this change would break their code. Moreover, it may break the possibility of lists of cascaded definitions like: Basically this change may drop support for any list attribute that is not a list of strings. That being said, I like the idea of a special treatment for lists of strings, that would map them directly to List available in EL. Good job! |
|
It appears there is no regression after all. The hack of cloning the Attribute does it, although it probably slows things down slightly. Could you please add the test case and I'll +1 this. |
|
@ brettryan have you had any luck with writing a testcase? |
|
Sorry, been out of action, wife's in hospital. I'll try get onto it when I can but it won't be this week unfortunately.
|
When using expressions using the following example:
We first encounter an NPE when attempting to access this object. This is due to Attribute#toString returning the value
nullwhich with the container attempting to turn this into a binary array cases an NPE. This has been resolved by returning the string"null".For the list attributes I have chosen to recursively process any lists encountered within [AbstractAttributeEvaluator#evaluate](https://tiles.apache.org/framework/apidocs/org/apache/tiles/evaluator/AbstractAttributeEvaluator.html#evaluate(org.apache.tiles.Attribute,%20org.apache.tiles.request.Request) to clone each attribute to a new instance with the value set to the evaluated expression.
NOTE: This solution comes with one caveat that is semi-intentional and you may choose to reject the pull request on this point. Previously a ListAttribute would be exposed to the view requiring consumers to make references to the attributes
valueproperty before accessing the index to the list.