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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Translate the entire conversation x

Custom Data Utility Multiline Text Display Issue After Upgrade

Anil_SAD
13-Aquamarine

Custom Data Utility Multiline Text Display Issue After Upgrade

Version: Windchill 13.0

 

Use Case: Custom Data Utility Multiline Text Display Issue After Upgrade


Description:

Hi there,

 

I'm experiencing an issue with the display of multiline text from a custom Data Utility after upgrading our Windchill environment from version 11.2 to 13.0.

 

I've developed a custom Data Utility which is used to display specific text information, retrieved from an attached Excel document, on the Attributes-Structure tab of WTParts( Thanks to @HelesicPetr  for idea 🙂 ).

 

This text data is structured to include multiple lines for readability (e.g., containing section headers and descriptions).

 

In Windchill 11.2, this Data Utility successfully displayed the text with proper line breaks, effectively creating a multiline output within the UI field/cell where the Data Utility is rendered.

 

1.png

 

However, after upgrading to Windchill 13.0, the exact same Data Utility code now displays all the text as a single continuous line. The intended line breaks are ignored, making the displayed information difficult to read and interpret.

2.png

Steps Taken (Troubleshooting):

  1. I confirmed that the Data Utility logic correctly reads the data from the Excel file and builds the output string with standard newline characters (\n) at the intended break points.

  2. Based on the observation that \n characters were not being interpreted as line breaks in 13.0, we modified the Data Utility code to explicitly replace the newline characters (\n) with HTML <br> tags before setting the value to the TextDisplayComponent.

  3. Upon viewing the modified Data Utility output in Windchill 13.0, we observed that the <br> tags themselves are displayed as literal text within the UI, rather than being interpreted as HTML line breaks. This indicates that the output of the TextDisplayComponent is being escaped and treated as plain text by the rendering mechanism in Windchill 13.0, despite our attempts to insert HTML.

 

Expected Behavior:

We expect the custom Data Utility to display the text with proper line breaks, as it did in Windchill 11.2, for improved readability.

 

Thank you for your time and assistance.

 

 

Btw here my code snippet for set value for textcomponent:

// Seviye değiştiyse veya ilk seviye ise
    	if (level != null && !level.equals(currentLevel)) {
    	currentLevel = level;

    	if (combinedValues.length() > 0) {
    	combinedValues.append("\n"); 
    	}
    	combinedValues.append("----------------------------------------").append(currentLevel).append("----------------------------------------").append("\n");
    	}
    	if (text != null && !text.isEmpty()) {
    	combinedValues.append(text).append("\n");
    	}
    	}

    	if (combinedValues.length() > 0) {
    	return combinedValues.toString();
    	}
    	} catch (Exception e) {
    	System.out.println("Error processing Excel file for document: " + latestDoc.getNumber());
    	e.printStackTrace();
    	}
    	}
    	}
    	} catch (Exception e) {
    	System.out.println("Error in getCombinedColumnAValues for part: " + part.getNumber());
    	e.printStackTrace();
    	}
    	return null;
    	}
    private TextDisplayComponent createTextDisplayComponent(String componentId, String value) {
        TextDisplayComponent textComp = new TextDisplayComponent(null);

        textComp.setId(componentId); 
        textComp.setValue(value); 
        textComp.setLongTextDisplayMode(true);
        textComp.disableMoreLink();
       // textComp.setTruncationLength(4000);
        textComp.setCheckXSS(false);
        
        return textComp;
    }

Anil.

8 REPLIES 8
Fadel
22-Sapphire III
(To:Anil_SAD)

take a look at https://www.ptc.com/en/support/article/CS362159 , change seems to be implemented in WC12

Fede
avillanueva
22-Sapphire III
(To:Fadel)

@Fadel is right on. I had to recode some of my customization to account for Rich Text change. 

HelesicPetr
22-Sapphire II
(To:Fadel)

Hi @Fadel 

I thought that the TextDisplayComponent is not the right component to use for the styled text output

PetrH

Anil_SAD
13-Aquamarine
(To:Fadel)

Hi @avillanueva @Fadel @HelesicPetr 

 

I've changed my component to HTMLText comp but its still single continuous line. Maybe my method is wrong about set value to this component,

 

Here my code snippet:

 

// Seviye değiştiyse veya ilk seviye ise
        	            if (level != null && !level.equals(currentLevel)) {
        	                currentLevel = level;
        	                
        	                if (combinedValues.length() > 0) {
        	                    combinedValues.append("\n"); 
        	                }
        	                combinedValues.append("----------------------------------------").append(currentLevel).append("----------------------------------------").append("\n");
        	            }

        	            
        	            if (text != null && !text.isEmpty()) { 
        	                combinedValues.append(text).append("\n");
        	            }
        	        } 

        	        if (combinedValues.length() > 0) {
                           
        	            return combinedValues.toString();
        	        }
        	    } catch (Exception e) {
        	        System.out.println("Error processing Excel file for document: " + latestDoc.getNumber()); 
        	        e.printStackTrace(); 
                    
        	    }
        	} 
    	    } 

    	} catch (Exception e) {
    	    System.out.println("Error in getCombinedColumnAValues for part: " + part.getNumber()); // Orijinal log
    	    e.printStackTrace(); 
    	}
         System.out.println("Could not find valid data in any described-by Excel documents for part: " + part.getNumber() + ". Returning null."); // Ek log kaldırıldı
    	return null; 
    }

    private HTMLText createHTMLTextComponent(String componentId, String value) throws WTException {
         System.out.println("Creating HTMLText component for componentId: " + componentId); 
        try {
           
            HTMLText htmlComp = HTMLText.newHTMLText(value);

            return htmlComp;
        } catch (WTPropertyVetoException e) {
             System.err.println("Error creating HTMLText component for componentId: " + componentId); 
            e.printStackTrace(); 

            throw new WTException(e);
        }
    }

    @Override
    public Object getPlainDataValue(String arg0, Object arg1, ModelContext arg2) throws WTException {
        // Product Structure Browser "Attributes" panel calls this.
    	System.out.println("Entering " + this.getClass().getName() + ".getPlainDataValue"); 

        if(arg1 instanceof WTPart) {
        	System.out.println("Returning Custom getPlainDataValue"); 

            WTPart part = (WTPart) arg1;
            try {
                 return getCombinedColumnAValues(part);
            } catch (Exception e) {
                 System.err.println("Error in getPlainDataValue calling getCombinedColumnAValues for part: " + part.getNumber()); // Log eklendi
                 e.printStackTrace(); // Orijinal hata basımı
                 return null;
            }

        } else {
            System.out.println("Returning OOTB getPlainDataValue"); 
            return null;
        }
    }

 

Also i've tried this too

  private HTMLText createHTMLTextComponent(String componentId, String value) throws WTException {
        System.out.println("Creating HTMLText component for componentId: " + componentId); 
        try {
            String htmlValue = value.replace("\n", "<br/>");

            HTMLText htmlComp = HTMLText.newHTMLText(htmlValue);

            return htmlComp;
        } catch (WTPropertyVetoException e) {
              System.err.println("Error creating HTMLText component for componentId: " + componentId); 
            e.printStackTrace(); 
            throw new WTException(e);
        }
    }

but it's the same the output is still single continuous line below.

Anil_SAD_0-1748938514749.png

 

 

Btw to workaround this issue, I've been looking for how to add my own "customizedTAB" to this panel. If i can add it i'll able to do everything i want with this customizedTab i think. I wanna place it right after Documents.

 

Anil_SAD_1-1748938682692.png

 

But as i remember @HelesicPetr 's old posts, it's difficult to customize these areas cause of its rendered by GWT. 

 

I've found we're able add some sections to TAB on the top side. like this post(This is for ChangeRequest) Link 

Anil_SAD_2-1748939316267.png

 

But i want to do add my own customized tab under stucture tab, so i need to find the ID of Default Attributes-Classifications-Visualization-Uses-Occurences ... to define them in custom-models.xml file.

 

I read almost 279 xml files in codebase\config\actions , so all i need is know is it feasible or not 🙂

HelesicPetr
22-Sapphire II
(To:Anil_SAD)

Hi @Anil_SAD 

What does a method getCombinedColumnAValues do? I would like to see a string output.

PetrH  

Anil_SAD
13-Aquamarine
(To:HelesicPetr)

Hi @HelesicPetr 

I sent you a message with the full code of the class 🙂
By the way, I figured out how to hook into the GWT-rendered section, but it doesn’t behave like a tab. It works more like a button. It didn’t feel very useful to me, so I gave up on that approach.


If someone else wants to try it:

Just need to hook codebase\netmarkets\javascript\psb\psb.js but the the crucial point is just you need to call your function after the page fully loaded. 

 

Anil_SAD_0-1750053046607.png

Anil.

HelesicPetr
22-Sapphire II
(To:Anil_SAD)

Hello @Anil_SAD 

I've found a right component to use 

very simple text with BR separator 

HelesicPetr_1-1750086830036.png

 

results

HelesicPetr_0-1750086803017.png

 

 You just have to use RichText datautility and set a value

use extends com.ptc.core.components.factory.dataUtilities.RichTextDataUtility

and return a com.ptc.core.components.rendering.guicomponents.RichTextDisplayComponent

public class MyFunction extends RichTextDataUtility
{
	@Override
	public Object getDataValue(String componentId, Object datum, ModelContext mc) throws WTException
	{
		Object retValue = super.getDataValue(componentId, datum, mc);
		if (retValue instanceof AttributeDisplayCompositeComponent)
		{
			AttributeDisplayCompositeComponent dc = (AttributeDisplayCompositeComponent) retValue;
			RichTextDisplayComponent ricText = (RichTextDisplayComponent) dc.getValueDisplayComponent();
			String combinedValues = "text enter text </BR> system separator text </BR> text next row";
			if (combinedValues != null)
			{
				ricText.setValue(combinedValues);
				return ricText;
			}
		}
		return null;
	}
}

 PetrH

Hello @Anil_SAD,

 

It looks like you have some responses from some community members. If any of these replies helped you solve your question, please mark the appropriate reply as the Accepted Solution. 

Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,
Vivek N.
Community Moderation Team.

Announcements

Top Tags