cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Translate the entire conversation x

jsp to get properties

BrianKrieger
10-Marble

jsp to get properties

I was putting together a jsp to display some custom properties. I thought I had used this code before to extract the properties but maybe I'm just dreaming. It has some wtdocs queryresult from a query, then....

if(curQR.size()>0){
while(curQR.hasMoreElements()){
Object nextDocument = curQR.nextElement();
String docName;
String docURL;
if("wt.doc.WTDocument".equalsIgnoreCase(nextDocument.getClass().getName())){
WTDocument curWTDoc = (WTDocument) nextDocument;
StringDefView docAttType = (StringDefView) IBADefinitionHelper.service.getAttributeDefDefaultViewByPath("tmpVal");
curWTDoc = (wt.doc.WTDocument)wt.iba.value.service.IBAValueHelper.service.refreshAttributeContainer(curWTDoc, null, null, null);
DefaultAttributeContainer dacCont = (DefaultAttributeContainer) curWTDoc.getAttributeContainer();
AbstractValueView[] docAttDefView = dacCont.getAttributeValues();
if(docAttDefView!=null){
if(docAttDefView.length>0){
StringValueDefaultView dacStringValue = (StringValueDefaultView) docAttDefView[0];
docName = "For document: " + curWTDoc.getName() + " wheelbase: " + dacStringValue.getValue();

It's attempting everything fine, so maybe it's my variable name ("tmpVal" in this case. That's the name of the variable when viewing the Type/Attribute manager.)? I know my object has that attribute and it is defined, so....? Would it be better to just scrap this and switch over to an embedded webject?

Thanks in advance!
Brian Krieger
Peterbilt Motors
4 REPLIES 4

On 04/17/13 11:22, Brian Krieger wrote:
>
> I was putting together a jsp to display some custom properties. I thought I had used this code before to extract the properties but maybe I'm just dreaming. It has some wtdocs queryresult from a query, then....
>
> if(curQR.size()>0){
>
> while(curQR.hasMoreElements()){
>
> Object nextDocument = curQR.nextElement();
>
> String docName;
>
> String docURL;
>
> if("wt.doc.WTDocument".equalsIgnoreCase(nextDocument.getClass().getName())){
>
> WTDocument curWTDoc = (WTDocument) nextDocument;
>
> StringDefView docAttType = (StringDefView) IBADefinitionHelper.service.getAttributeDefDefaultViewByPath("tmpVal");
>
> curWTDoc = (wt.doc.WTDocument)wt.iba.value.service.IBAValueHelper.service.refreshAttributeContainer(curWTDoc, null, null, null);
>
> DefaultAttributeContainer dacCont = (DefaultAttributeContainer) curWTDoc.getAttributeContainer();
>
> AbstractValueView[] docAttDefView = dacCont.getAttributeValues();
>
> if(docAttDefView!=null){
>
> if(docAttDefView.length>0){
>
> StringValueDefaultView dacStringValue = (StringValueDefaultView) docAttDefView[0];
>
> docName = "For document: " + curWTDoc.getName() + " wheelbase: " + dacStringValue.getValue();
>
> It's attempting everything fine, so maybe it's my variable name ("tmpVal" in this case. That's the name of the variable when viewing the Type/Attribute manager.)? I know my object has that attribute and it is defined, so....? Would it be better to just scrap this and switch over to an embedded
> webject?
>

I use the following code to extract an IBA with name "RELEASE_NUMBER":
//obj = //some EPMDocument
IBAHolder ibaHolder = wt.iba.value.service.IBAValueHelper.service.refreshAttributeContainer((wt.iba.value.IBAHolder)obj, null, null, null);
wt.iba.definition.service.StandardIBADefinitionService defService = new wt.iba.definition.service.StandardIBADefinitionService();
wt.iba.value.DefaultAttributeContainer attributeContainer = (wt.iba.value.DefaultAttributeContainer)ibaHolder.getAttributeContainer();
AttributeDefDefaultView attributeDefinition = defService.getAttributeDefDefaultViewByPath("RELEASE_NUMBER");
StringValueDefaultView attValue = (StringValueDefaultView)attributeContainer.getAttributeValues(attributeDefinition)[0];
String releaseNumber = attValue.getValue().trim();

You might try using "TMPVAL" instead of "tmpVal" for the variable name.

See also the following post by Matthew Hoover for the excellent examples to get/set various types of IBA's:

Hey, Randy,

Thanks for the note! I am still a little puzzled why I still can't get this to work. I assume I didn't have it working before, given this one isn't going well. I've written the call in a bunch of different ways at this point (to no avail......sigh.....). I did notice that it seems most of the examples use an EPMDoc (and I'm just using a WTDoc). Can't imagine that would make a difference (as ibaHolder is one abstraction "up" for both of those....I think.....).

Again, I appreciate the help!
Brian Krieger

Brian,

I missed what version of Windchill you are using, but I'd suggest to start using the com.ptc.core.lwc.server.LWCNormalizedObject class if you can as it provides a lot of this functionality. The JavaDoc has some examples of how to invoke to query and update values.

Thanks,
Jason Schrader

Hey, Jason,

Thanks for the reply. We're on 10.1 m020. That worked. I think I'm going now.

Thanks to Randy, too!

I appreciate it!
BK
Announcements

Top Tags