thx,
but right now, this doesn't really help me, because i'm doing a complete different aproach (at least i think so, when it comes to the Expando i'm never entirely sure what happens -.-).
So my code to get the Information of a Custom Field looks like this:
1
2public ExpandoValue getValue(String fieldName) throws SystemException, PortalException{
3 return ExpandoValueLocalServiceUtil.getValue(user.getCompanyId(), User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME, fieldName, user.getUserId());
4}
5
6public String getDisplayValue(String key) throws SystemException, PortalException{
7 ExpandoValue value = getValue(key);
8 if(key == PROPERTY_BEHOERDE){
9 return (String) BEHOERDE_DESC.get(value.getInteger());
10 }
11 if(key == PROPERTY_EINRICHTUNG){
12 return (String) EINRICHTUNG_DESC.get(value.getInteger());
13 }
14 if(value != null){
15 return value.getData();
16 }else{
17 return "";
18 }
19 }
And that works completely finde... But the Problem comes, when i want to edit the Values of a Custom Field for a User, if i havn't set a value for it yet (meaning i never gave this custom Field a specific value after creating it):
1
2 public void setValue(String key, Object value, String type) throws SystemException, PortalException{
3 ExpandoValue expandoValue = getValue(key);
4 if(type == "Integer"){
5 expandoValue.setInteger(Integer.parseInt((String) value));
6 }
7 if(type == "String"){
8 expandoValue.setString((String)value);
9 }
10 ExpandoValueLocalServiceUtil.updateExpandoValue(expandoValue);
11 }
The Problem here is, that "getValue(key) returns null, because that Custom Field for the User does not has a value yet, so right now i have no means of initializing the ExpandoValue, because i get back null instead of an empty ExpandoValue...
I wanted to try the EpandoValueLocalServiceUtil.createExpandoValue, but that method wants an ID, and i don't know how i can look up all the other IDs for the ExpandoTable and simply make it the highest ID +1...
Edit: The really strange thing is... sometimes it works! I don't know y, but today, after starting my eclipse and develop server, assigning the new field works! I could simply insert a value and everything worked... but i have absolutely no idea, why...
after deleting theCustom Field and creating it again (it was just a testfield), the same problem happens again (getting null back when i use my "getValue" method)...
Por favor, faça login para denunciar.