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 the Community Ranking System, a fun gamification element of the PTC Community. X

How to Display Integer Attribute Values without a Comma?

ScottMorris
17-Peridot

How to Display Integer Attribute Values without a Comma?

Hi, could someone confirm the inability to display an integer attribute value without a comma? I never expected this to be a limitation, but found the following ideas to support it.

Integer Attribute DisplayInteger Attribute Display

If there is no way to remove the commas, does anyone have a good way to validate a string attribute to ensure it only contains integers? I'm guessing a Regular Expression constraint on the attribute?

 

Would be nice to use the Integer attrbute, so please vote up the ideas if you agree.

 

ACCEPTED SOLUTION

Accepted Solutions

Yes, you are absoulutely right. 

but to make it work for folder page, its not a big deal. Simply add below extry to site.xconf for the IBA internal name and propagate the changes and restart MS and you're all set.

 

 

<!-- Thie entry is added to display Interger Number without command on Folder page -->
   <Property name="wt.services/svc/default/com.ptc.core.components.descriptor.DataUtility/IBA|com.ptc.ptcnet.SalesOrderNumber/java.lang.Object/0"
             overridable="true"
             targetFile="codebase/service.properties"
             value="ext.DataUtilities.CustomNumberFormatDataUtility/singleton"/>

 

 jcaDebug.png

 

 

 

Where,

IBA|com.ptc.ptcnet.SalesOrderNumber is a IBA internal display as displayed when you apply &jcaDebug=1 to folder page. And,

ext.DataUtilities.CustomNumberFormatDataUtility is a fully qualified classname for data utility.

 

Results will be like this:

folderpage.png

 

I hope this helps you.

 

Regards,

Shirish 

 

 

 

View solution in original post

4 REPLIES 4

Hi Scott,

 

you can do so by writing custom data utility and registering it against the attribute. I am able to display integer value without comma using below code snippet:

 

public class CustomNumberFormatDataUtility extends DefaultDataUtility {

	@Override
	public Object getDataValue(String arg0, Object arg1, ModelContext arg2) throws WTException {
		System.out.println(" *** Inside CustomNumberFormatDataUtility");
		
		Object superval = super.getDataValue(arg0, arg1, arg2);
		
		ComponentMode mode = arg2.getDescriptorMode();
		if (!(ComponentMode.CREATE.equals(mode) || ComponentMode.EDIT.equals(mode)))
		{
			System.out.println("*** Not a Create/Edit View");
			if(superval.getClass().equals(AttributeDisplayCompositeComponent.class)){
				AttributeDisplayCompositeComponent oldgui=(AttributeDisplayCompositeComponent)superval;
				if (oldgui.getValueDisplayComponent().getClass().equals(NumericDisplayComponent.class)){
					AttributeDisplayCompositeComponent gui=new AttributeDisplayCompositeComponent("composite");
					TextDisplayComponent textGUI= new TextDisplayComponent("text");
					textGUI.setValue(oldgui.getPrintableValue().replaceAll(",", ""));
					gui.setValueDisplayComponent(textGUI);
					return gui;
				}
			}
			return superval;
		}else{
			return superval;
		}
	}
}

Here is the output:

IBADisplay.png

 

 

 

But this data utility works only for Info-Page, Edit, Create etc. pages, but not for folder or table columns.

Yes, you are absoulutely right. 

but to make it work for folder page, its not a big deal. Simply add below extry to site.xconf for the IBA internal name and propagate the changes and restart MS and you're all set.

 

 

<!-- Thie entry is added to display Interger Number without command on Folder page -->
   <Property name="wt.services/svc/default/com.ptc.core.components.descriptor.DataUtility/IBA|com.ptc.ptcnet.SalesOrderNumber/java.lang.Object/0"
             overridable="true"
             targetFile="codebase/service.properties"
             value="ext.DataUtilities.CustomNumberFormatDataUtility/singleton"/>

 

 jcaDebug.png

 

 

 

Where,

IBA|com.ptc.ptcnet.SalesOrderNumber is a IBA internal display as displayed when you apply &jcaDebug=1 to folder page. And,

ext.DataUtilities.CustomNumberFormatDataUtility is a fully qualified classname for data utility.

 

Results will be like this:

folderpage.png

 

I hope this helps you.

 

Regards,

Shirish 

 

 

 

Thank you for sharing this solution. Its a bit of complex, customization solution that I'm not be comfortable with yet due to the maintenance and validation. I am looking forward to testing it to learn more about  how it works. 

 

Personally, I hope people will vote up the two ideas and PTC will add some simple display options for integer attributes. I wish they had not hardcoded the display settings to use commas.

 

For our implementation, we've decided to switch to a string attribute and apply a regex constraint to it, to only allow integers. The error message is not pretty if the user does not enter the right value, but it was easy to implement and easy to maintain.

 

regex_validation.png

Announcements

Top Tags