Grundlegende Anpassung > User Interface Customization > MVC Components > MVC Tables > Converting an Existing Table Implementation to MVC
Converting an Existing Table Implementation to MVC
Overview
This section describes the mapping of attributes from the 9.x legacy tags to the corresponding attributes on the new MVC table builders.
describeTable
The content of the describeTable tag is now specified in the buildComponentConfig method of ComponentConfigBuilder interface
JSP code was like this:
<jca:describeTable var="tableDescriptor" id="netmarkets_project_list"
configurable="true"
type="wt.projmgmt.admin.Project2" label="${projectListLabel}">
MVC code will look like this:
@ComponentBuilder(“netmarkets_project_list”)
public class ProjectListBuilder extends AbstractConfigurableTableBuilder {

@Override
public ComponentConfig buildComponentConfig(ComponentParams params) {
ComponentConfigFacory factory = getComponentConfigFactory();
TableConfig table = factory.newTableConfig();
table.setLabel(ClientMessage.get(RESOURCE,"PROJECT_LIST_NAME");
table.setType("wt.projmgmt.admin.Project2");

return table;
}
describeColumn
The content of the describeColumn tag is also specified in the buildComponentConfig method of ComponentConfigBuilder interface. As the column component is an child component of the table component, it is added to the table config.
JSP code was like this:
<describeTable var="tableDescriptor" type="wt.part.WTPart"
id=" test.table" label="testTable" >
<describeColumn id="name" sortable=”true”/>
<describeColumn id="number"/>
</describeTable>
MVC code will look like this:
TableConfig table = factory.newTableConfig();

table.addComponent(factory.newColumnConfig(“name”,true));
table.addComponent(factory.newColumnConfig(“number”,false));

renderTable
The content of the renderTable tag is also specified in the buildComponentConfig method of ComponentConfigBuilder interface.
JSP code was like this:
<jca:renderTable showCustomViewLink="false" model="${tableModel}" showCount="true"
showPagingLinks="true" />
MVC code will look like this:
TableConfig table = factory.newTableConfig();

table.setShowCount(true);
table.setShowCustomViewLink(false);

getModel
The content of the getModel tag is specified in the buildComponentData method of ComponentDataBuilder interface.
JSP code was like this:
<jca:getModel var="tableModel" descriptor="${tableDescriptor}"
serviceName="com.ptc.netmarkets.projmgmt.ProjectCommands"
methodName="getProjects" ……. >
<jca:addServiceArgument value="${user}" type="wt.org.WTUser"/>
<jca:addServiceArgument value="${pseudoType}" type="java.lang.Integer"/>
</jca:getModel>
MVC code will look like this:
@Override
public QueryResult buildComponentData(ComponentConfig config,
ComponentParams params) {
WTPrincipal user = SessionHelper.getPrincipal();
return ProjectCommands.getProjects(user,0)
}
War dies hilfreich?