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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

I am not able to display the contents in the table.

SHRI_HARI
6-Contributor

I am not able to display the contents in the table.

I was working in a project where I should only show a particular subtype of Document in a table. I was putting my code for that and finally I got the table but the contents inside the table ie Name of the document or Number of the Document are not visible. Here I am attaching my code and I am sending the pic of that can anyone say what is the alteration I should do in this code to make my contents in the table.

 

My Code:

/* bcwti
*
* Copyright (c) 2010 Parametric Technology Corporation (PTC). All Rights Reserved.
*
* This software is the confidential and proprietary information of PTC
* and is subject to the terms of a software license agreement. You shall
* not disclose such confidential information and shall use it only in accordance
* with the terms of the license agreement.
*
* ecwti
*/
package com.ptc.training.mvc;

import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.CHANGE_STATUS_FAMILY;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.CONTAINER_NAME;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.FORMAT_ICON;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.GENERAL_STATUS_FAMILY;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.ICON;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.INFO_ACTION;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.LAST_MODIFIED;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.NAME;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.NM_ACTIONS;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.NON_SELECTABLE_COLUMN;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.NUMBER;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.ORG_ID;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.SHARE_STATUS_FAMILY;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.STATE;
import static com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers.VERSION;

import wt.fc.PersistenceHelper;
import wt.fc.QueryResult;
import java.io.*;
import java.lang.String;
import wt.doc.*;
import wt.services.applicationcontext.implementation.*;
import wt.query.*;
import wt.vc.*;
import wt.type.*;
import com.ptc.core.meta.common.*;
import wt.pds.StatementSpec;
import wt.query.QuerySpec;
import wt.util.WTException;

import com.ptc.mvc.components.ComponentBuilder;
import com.ptc.mvc.components.ComponentConfig;
import com.ptc.mvc.components.ComponentDataBuilder;
import com.ptc.mvc.components.ComponentParams;
import com.ptc.mvc.ds.server.jmx.PerformanceConfig;
import com.ptc.core.htmlcomp.components.ConfigurableTableBuilder;
import com.ptc.core.htmlcomp.components.JCAConfigurableTable;
import com.ptc.core.htmlcomp.createtableview.Attribute;
import com.ptc.core.htmlcomp.tableview.ConfigurableTable;
import com.ptc.core.htmlcomp.tableview.SortColumnDescriptor;
import com.ptc.core.htmlcomp.tableview.TableColumnDefinition;
import com.ptc.core.htmlcomp.tableview.TableViewDescriptor;
import com.ptc.jca.mvc.components.JcaColumnConfig;
import com.ptc.mvc.components.AbstractComponentConfigBuilder;
import com.ptc.mvc.components.ColumnConfig;
import com.ptc.mvc.components.ComponentConfigFactory;
import com.ptc.mvc.components.TableConfig;
import com.ptc.mvc.util.ClientMessageSource;
import com.ptc.carambola.property.PropertyUtils;
import com.ptc.mvc.components.AbstractComponentBuilder;
import com.ptc.mvc.components.AttributeConfig;
import com.ptc.mvc.components.AttributePanelConfig;

/**
* Builder for a table with componentId = carambola.mvc.table
*
* <B>Supported API: </B>false <BR>
* <BR>
* <B>Extendable: </B>false
*
* @version 1.0 D:\ptc\Windchill\Windchill\codebase\com\ptc\training\mvc\builder
*
*/
@ComponentBuilder("com.ptc.training.mvc.testrequest")
public class TestRequest extends AbstractComponentBuilder {

private static final String RESOURCE = "com.ptc.carambola.carambolaResource";

private final ClientMessageSource messageSource = getMessageSource(RESOURCE);

@Override
public ComponentConfig buildComponentConfig(ComponentParams params) throws WTException {
/**
* Set properties that used to be on <describeTable>
*/
ComponentConfigFactory factory = getComponentConfigFactory();
TableConfig table = factory.newTableConfig();

table.setLabel(messageSource.getMessage("TESTREQ_TABLE_LABEL"));
table.setSelectable(true);
table.setType("wt.doc.WTDocument");
//table.setActionModel("CustomToolbar");
table.setActionModel("mynewmodel");

/**
* These are properties that used to be set on <renderTable>
*/
table.setShowCount(true);
table.setShowCustomViewLink(true);

table.addComponent(factory.newColumnConfig(ICON, true));
ColumnConfig col = factory.newColumnConfig(NAME, true);
// This is how to set a column to have variable height
// ((JcaColumnConfig)col).setVariableHeight(true);

// specifying a custom javascript function for the column
col.setCompareJsFunction("PTC.carambola.customCompareFunction");

table.addComponent(col);
table.addComponent(factory.newColumnConfig(FORMAT_ICON, false));
table.addComponent(factory.newColumnConfig(NUMBER, true));
table.addComponent(factory.newColumnConfig(ORG_ID, false));
table.addComponent(factory.newColumnConfig(INFO_ACTION, false));
ColumnConfig nmActionsCol = factory.newColumnConfig(NM_ACTIONS, false);
((JcaColumnConfig) nmActionsCol).setActionModel("CustEx_table_row_actions");
table.addComponent(nmActionsCol);

table.addComponent(factory.newColumnConfig(SHARE_STATUS_FAMILY, false));
table.addComponent(factory.newColumnConfig(GENERAL_STATUS_FAMILY, false));
table.addComponent(factory.newColumnConfig(CHANGE_STATUS_FAMILY, false));

// State column is a DataStore-only column
ColumnConfig stateColumn = factory.newColumnConfig(STATE, true);
stateColumn.setDataStoreOnly(true);
table.addComponent(stateColumn);

ColumnConfig strikeThroughColumn = factory.newColumnConfig("strikeThroughRow", false);
strikeThroughColumn.setDataStoreOnly(true);
strikeThroughColumn.setNeed("endItem");
table.addComponent(strikeThroughColumn);
table.setStrikeThroughColumn(strikeThroughColumn);

//table.addComponent(factory.newColumnConfig(VERSION, false));
//table.addComponent(factory.newColumnConfig(LAST_MODIFIED, false));
table.addComponent(factory.newColumnConfig(CONTAINER_NAME, false));
ColumnConfig col2 = factory.newColumnConfig(NON_SELECTABLE_COLUMN, false);
col2.setDataStoreOnly(true);
col2.setNeed("endItem");
table.addComponent(col2);
table.setNonSelectableColumn(col2);
table.setView("/carambola/carambolaMVCExampleTable.jsp");

return table;
}


@Override
public QueryResult buildComponentData(ComponentConfig config, ComponentParams params) throws WTException {
final IdentifierFactory IDENTIFIER_FACTORY = (IdentifierFactory) DefaultServiceProvider.getService(IdentifierFactory.class, "logical");
TypeIdentifier tid = (TypeIdentifier) IDENTIFIER_FACTORY.get("WCTYPE|wt.doc.WTDocument|com.plmtestlab.plmcentimg.SuperCars.typeRequest");

QuerySpec qs = new QuerySpec();

int idx = qs.addClassList(WTDocument.class, true);

SearchCondition sc = TypedUtilityServiceHelper.service.getSearchCondition(tid, true);

qs.appendWhere(sc, new int[] { idx });

qs.appendAnd();

int index = 0;

qs.appendWhere(new SearchCondition(WTDocument.class, Iterated.LATEST_ITERATION, SearchCondition.IS_TRUE), new int[] { index });
System.out.println("qs:"+qs.toString());
QueryResult qr= PersistenceHelper.manager.find((StatementSpec) qs);
return qr;
}
}

1 ACCEPTED SOLUTION

Accepted Solutions

The problem is the QueryResult

 

Please change the method

public QueryResult buildComponentData(ComponentConfig config, ComponentParams params) throws WTException {
--> to
public
Object buildComponentData(ComponentConfig config, ComponentParams params)

and change the end of the method

QueryResult qr= PersistenceHelper.manager.find((StatementSpec) qs);
return qr;
--> to
return new
WTArrayList(PersistenceHelper.manager.find((StatementSpec) qs));

 

View solution in original post

3 REPLIES 3

Following needs to be set to false, since you don't have a configurable table:

table.setShowCustomViewLink(true);

 

I would first remove all the not needed columns, just to check if it works. e.g. the state, strikeThrough and also remove the javascript (PTC.carambola.customCompareFunction)

 

I have removed those and tried it still same problem is there.

The problem is the QueryResult

 

Please change the method

public QueryResult buildComponentData(ComponentConfig config, ComponentParams params) throws WTException {
--> to
public
Object buildComponentData(ComponentConfig config, ComponentParams params)

and change the end of the method

QueryResult qr= PersistenceHelper.manager.find((StatementSpec) qs);
return qr;
--> to
return new
WTArrayList(PersistenceHelper.manager.find((StatementSpec) qs));

 

Announcements