CIValue.getValue() vs CIValue.getInsertString()
Posted: Wed Jan 09, 2013 11:44 pm
Here's what I want. I have an attribute called "resourceUuid" that is a reference to another element's "uuid" attribute. In the attribute editing window or in the ctrl-space drop down list in text editing mode, I want to present the user with a list of valid values, but since the value are UUIDs, they aren't very human readable.
Instead of something like:
0524c6b8-8d73-491d-9794-3a02bbe5433c
2ccccf94-871f-4580-8fa6-4db78c54687c
342db3fe-bfe7-4103-a29f-d19bf6b1d1f1
43a68c36-079c-4c73-8c9d-e66221327112
I want to present then with something like:
Student Edition, Unit page 1.1 (Unit-1.1.pdf) 0524c6b8-8d73-491d-9794-3a02bbe5433c
Student Edition, Unit page 1.2 (Unit-1.2.pdf) 2ccccf94-871f-4580-8fa6-4db78c54687c
Student Edition, Unit page 1.3 (Unit-1.3.pdf) 342db3fe-bfe7-4103-a29f-d19bf6b1d1f1
Student Edition, Unit page 1.4 (Unit-1.4.pdf) 43a68c36-079c-4c73-8c9d-e66221327112
I've implemented a SchemaManagerFilter. In the filterAttributeValues method, I return a list of CIValues, which return a different value for getValue() and getInsertString(). According to the documentation, getInsertString() should return "the String to be inserted in the document", and getValue() should return "the actual value." Well, that's as clear as mud. I return CIValues that have the UUID for the insertString value, and the friendly text for the value.
It works as I would expect in text edit mode when I press ctrl-space to get a list of possible values. The list contains the human-friendly values, and when one of those friendly values is selected, just the UUID is inserted into the document. Perfect. That's exactly what I wanted. However, it does NOT work when editing the attribute value in the Author Mode. The dropdown list presents a the same human-friendly list of items, but when I select one, the human-friendly text (the same text in the dropdown) is inserted into the document instead of just the UUID.
Okay, since the documentation sucks (to put in mildly), I decided to just see happens in the debugger. I implement a class called MyCIValue, which extends CIValue, but just logs some debugging output and calls super. I then set a breakpoint in getInsertString(). In text mode, when selecting an item for the list, getInsertString() is called, and the value that it returns is inserted into the document. However, when in Author Mode, getInsertString() is not called.
Got any suggestions for how I can get this to work properly? It would be a lot easier to debug your code if it wasn't obfuscated, but judging by what I've seen, I don't blame you for obfuscating it. I would be ashamed of it too.
Instead of something like:
0524c6b8-8d73-491d-9794-3a02bbe5433c
2ccccf94-871f-4580-8fa6-4db78c54687c
342db3fe-bfe7-4103-a29f-d19bf6b1d1f1
43a68c36-079c-4c73-8c9d-e66221327112
I want to present then with something like:
Student Edition, Unit page 1.1 (Unit-1.1.pdf) 0524c6b8-8d73-491d-9794-3a02bbe5433c
Student Edition, Unit page 1.2 (Unit-1.2.pdf) 2ccccf94-871f-4580-8fa6-4db78c54687c
Student Edition, Unit page 1.3 (Unit-1.3.pdf) 342db3fe-bfe7-4103-a29f-d19bf6b1d1f1
Student Edition, Unit page 1.4 (Unit-1.4.pdf) 43a68c36-079c-4c73-8c9d-e66221327112
I've implemented a SchemaManagerFilter. In the filterAttributeValues method, I return a list of CIValues, which return a different value for getValue() and getInsertString(). According to the documentation, getInsertString() should return "the String to be inserted in the document", and getValue() should return "the actual value." Well, that's as clear as mud. I return CIValues that have the UUID for the insertString value, and the friendly text for the value.
It works as I would expect in text edit mode when I press ctrl-space to get a list of possible values. The list contains the human-friendly values, and when one of those friendly values is selected, just the UUID is inserted into the document. Perfect. That's exactly what I wanted. However, it does NOT work when editing the attribute value in the Author Mode. The dropdown list presents a the same human-friendly list of items, but when I select one, the human-friendly text (the same text in the dropdown) is inserted into the document instead of just the UUID.
Okay, since the documentation sucks (to put in mildly), I decided to just see happens in the debugger. I implement a class called MyCIValue, which extends CIValue, but just logs some debugging output and calls super. I then set a breakpoint in getInsertString(). In text mode, when selecting an item for the list, getInsertString() is called, and the value that it returns is inserted into the document. However, when in Author Mode, getInsertString() is not called.
Got any suggestions for how I can get this to work properly? It would be a lot easier to debug your code if it wasn't obfuscated, but judging by what I've seen, I don't blame you for obfuscating it. I would be ashamed of it too.