I have some java code which returns me a map, and I want to access this in XSLT.
I just saved the result in some variable called $map.
Tried accessing the value as key($map,'key1') with no luck.
where $map is what some java method returned and key1 is the key of one map entry.
I want to fetch its value.
Any suggestions ?
Related
I have Map variable in my Freemarker template. How can I fetch a value at a particular key in the map, as we do in Java (map.get(<key>)).
I know how to iterate through keys and values of a map in a FTL. But I want a solution without iteration, on the lines of Java get() method of Map interface.
map[dynamicKey] or map.staticKey if the key is a string. Due to historical limitations, if the key isn't a string, map?api.get(nonStringKey).
I have a Map collection that stores "stops" as Key and a set of grid and time results as an Object value. e.g.
Key: [stops]
Value: [[{grid_item=Grid1, time=09:30}, {grid_item=Grid13, time=10:00}, {grid_item=Grid3, time=10:15}, {grid_item=Grid10, time=10:35}]]
Is there a way to separate the Value results, because i would like to use the grid_item and time to send them to another method. How can i get those values specifically?
Or should i store again the values in a Map but now the keys are grid_item and time. But how can i do that?
Any Suggestions?
You can access a specific object in your value's array this way:
map.get(stops)[0] // grid_item=Grid1, time=09:30
map.get(stops)[1] // grid_item=Grid13, time=10:00
....
where stops is the key that you are using.
I have a situation where I need to change(remove will also work) value corresponding to a key in a Map.
There are so many pairs in map. I don't want to copy all and create new map in change value for Map.
Is there any way I can directly change/remove value corresponding to a key.
I have tried changing complete map like :
Map m = commandParameters;
m.put("AID","");
return m;
But commandParameters is not resolved.
I tried changing that particular entry using random expressions, but could not work out.
Is there any way to do so?
**EDIT : ** commandParameters is original map.
Just do a remove on the map for a specific key.
commandParameters.remove("AID");
commandParameters.put("AID", "newvalue");
return commandParameters;
I have a MultiValueMap like
{3=[c-2, c-2], 2=[b-1, b-1], 1=[a-1, a-2, a-3]}
At one point I have to update a single value of a specific key
for example I have to update the key 2 like
2=[u-1,u-2]
how can i do this?
I've never used that library - but I would expect these two examples to do what you need:
multiMap.getCollection(2).clear();
multiMap.putAll(2, Arrays.asList("u-1", "u-2"));
Or
Collection c = multiMap.getCollection(2);
c.clear();
Collections.addAll(c, "u-1", "u-2");
The safest way is to call getCollection() to retrieve the current mapping, remove(key) to clear that mapping, iterate the retrieved collection to re-insert values that you want to keep, and/or add the new values.
If you know the type of collection used for a mapping (because you've called the constructor that takes collectionFactory), you could get the collection and update it directly.
Is there any way to tell Glassfish that the hash value for a certain data member of an entity class should be calculated and stored in the database instead of the original value?
If you modify the getter of a field to produce its hash instead of original value, you might end up with the hash stored instead.
If your database has a hash function, other option is to issue native query using entitiy manager.
Give it a try