Community Tip - You can change your system assigned username to something more personal in your community settings. X
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.
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.
Steps Taken (Troubleshooting):
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.
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.
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.
take a look at https://www.ptc.com/en/support/article/CS362159 , change seems to be implemented in WC12
@Fadel is right on. I had to recode some of my customization to account for Rich Text change.
Hi @Fadel
I thought that the TextDisplayComponent is not the right component to use for the styled text output
PetrH
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.
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.
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
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 🙂
Hi @Anil_SAD
What does a method getCombinedColumnAValues do? I would like to see a string output.
PetrH
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.
Hello @Anil_SAD
I've found a right component to use
very simple text with BR separator
results
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.