I have a problem with displaying a dynamic number of tables based on the number types (from an int variable called loadProfile) in the vector that holds the data.
The vector that holds the data (InitialMarginHolder.java):
package com.om.condico.margin.client.web.bo.initial;
import com.om.condico.util.interfaces.Searchable; import com.om.condico.util.GenericFactory; import com.om.condico.util.exception.CondicoException; import com.om.condico.margin.client.web.adaptor.initial.IControlProvider;
import java.util.Vector;
public class InitialMarginHolder {
Vector initialmargins;
Searchable searchCriteria = null;
IControlProvider provider = getProvider(); /**
* Constructor for InitialMarginHolder
*/
public InitialMarginHolder() {
initialmargins = new Vector();
}/**
* Returns all initial margins
* @return initialmargins
* @throws CondicoException
*/
public Vector getInitialMargins() throws CondicoException {
if (provider == null) {
throw new CondicoException("Unable to create a class instance that implements interface " + IControlProvider.class.getName());
}
initialmargins = provider.fetchInitialMargins(searchCriteria);
return initialmargins;
} /**
* Set the initial margins
* @param initialmargins the vector that holds the initial margins
*/
public void setInitialMargins(Vector initialmargins) {
this.initialmargins = initialmargins;
} public Searchable getSearchCriteria() {
return searchCriteria;
} public void setSearchCriteria(Searchable searchCriteria) {
this.searchCriteria = searchCriteria;
}/**
* Get the data object from the properties file
* @return the class name of the data object
*/
private IControlProvider getProvider() {
GenericFactory factory = new GenericFactory("condico.web.properties");
return (IControlProvider) factory.create(IControlProvider.class);
}
}
---------
The LocalInitialMargin is the object with the data within it. It is just a constructor and setters plus getters on each field/column value (LocalInitialMargin.java):
public LocalInitialMargin(String companyName, String accountName, java.util.Date reportDate, int eod, String deliveryPeriod, int loadProfile, String loadProfileName, String hours, long boughtVolume, long soldVolume, long netPosition, Quantity settlementPrice, String valuationParameter, Quantity marginRequirement)
----------------
The mockup-data I use (before the service-bean is done) consist of (ControlProviderMockup.java):
package com.om.condico.margin.client.web.adaptor.initial;
import com.om.condico.util.interfaces.Searchable; import com.om.condico.util.quantity.Quantity; import com.om.condico.margin.client.web.bo.MarginInput; import com.om.condico.margin.client.web.bo.initial.LocalInitialMargin; import com.om.condico.margin.client.web.adaptor.initial.IControlProvider;
import java.util.Vector;
/** * Mockup implementation for the IControlProvider interface. * Only for test purposes. * * @author bardae */
public class ControlProviderMockup implements IControlProvider {
/** Creates a new instance of ControlProviderMockup */
public ControlProviderMockup() {
}/** Gets initial margins matching a specific set of search criteria
*
* @param companyName the name of the company
* date getting initial margin done on this date
* eod getting initial margins done either end-of-day or intra-day
*
* @return an vector that holds objects of type LocalTrade; trades that
* matches the search criteria. If the object has no Trades, no data
* matched the search criteria
*/
public Vector fetchInitialMargins(Searchable searchCriteria) {
MarginInput mi = (MarginInput) searchCriteria;
Vector initialmargins = new Vector();
Quantity quant1 = new Quantity("16.50");
Quantity quant2 = new Quantity("623.12");for (int i = 0; i < 20; i++) {
LocalInitialMargin myInitialMargin = new LocalInitialMargin(
mi.getCompanyName(), mi.getAccountName(), mi.getReportDate(), mi.getEod(),
"June - " + i, 1, "POWER1 - Base Load", "24", 12, 10, 7, quant1, "25%", quant2);
initialmargins.add(myInitialMargin);
LocalInitialMargin myInitialMargin2 = new LocalInitialMargin(
mi.getCompanyName(), mi.getAccountName(), mi.getReportDate(), mi.getEod(),
"June - " + i, 2, "POWER2 - Peak Load", "12", 12, 10, 7, quant1, "25%", quant2);
initialmargins.add(myInitialMargin2);
}
return initialmargins;
}
}
-----------------
I initialize the data using an action-file (InitializeInitialMarginAction.java):
package com.om.condico.margin.client.web.servlet.initial;
import org.apache.struts.action.Action; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.om.condico.margin.client.web.bo.initial.InitialMarginHolder;
public class InitializeInitialMarginAction extends Action {
/**
* Contructor for InitializeInitialMarginAction
*/
public InitializeInitialMarginAction() {
}public InitialMarginHolder imh = new InitialMarginHolder();
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
request.getSession().putValue("initialmargins", imh);
// Forward control to the specified success URI
return (mapping.findForward("InitializeInitialMargin"));
}
}
---------------The jsp-file that displays the result from the query should produce a number of tables based on the loadProfile-variable (value 1 and 2 in the mockup data) (result.jsp):
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<bean:write name="initialmargins" property="accountName"/>
<display:table name="initialmargins" property="initialMarginsBase" scope="session" width="100%" pagesize="100" requestURI="result.jsp" decorator="org.apache.taglibs.display.test.ColumnsWrapper">
<display:column title="<%=ldeliveryPeriod%>" property="deliveryPeriod" sort="true" nulls="true" width="10%"/>
<display:column title="<%=lhours%>" property="hours" sort="true" nulls="true" width="10%"/>
<display:column title="<%=lboughtVol%>" property="boughtVolume" sort="true" nulls="true" nulls="true" width="10%"/>
<display:column title="<%=lsoldVol%>" property="soldVolume" sort="true" nulls="true" width="10%"/>
<display:column title="<%=lnetPosition%>" property="netPosition" sort="true" nulls="true" width="10%"/>
<display:column title="<%=lsettlementPrice%>" property="settlementPrice" sort="true" nulls="true" width="10%"/>
<display:column title="<%=lvaluationParameter%>" property="valuationParameter" sort="true" nulls="true" width="10%"/>
<display:column title="<%=lmarginRequirement%>" property="marginRequirement" sort="true" nulls="true" width="10%"/>
<display:setProperty name="paging.banner.one_item_found" value="" />
<display:setProperty name="paging.banner.all_items_found" value="" />
<display:setProperty name="paging.banner.some_items_found" value="" />
<display:setProperty name="paging.banner.include_first_last" value="false" />
<display:setProperty name="export.amount" value="page" />
<display:setProperty name="export.excel.include_header" value="true" />
<display:setProperty name="paging.banner.group_size" value="6" />
<display:setProperty name="paging.banner.prev_label" value="<%=lback%>" />
<display:setProperty name="paging.banner.next_label" value="<%=lforward%>" />
<display:setProperty name="sort.behavior" value="page" />
</display:table>
</td>
<td>
<bean:write name="initialmargins" property="accountName"/>
<display:table name="initialmargins" property="initialMarginsPeak" scope="session" width="100%" pagesize="100" requestURI="result.jsp" decorator="org.apache.taglibs.display.test.ColumnsWrapper">
<display:column title="<%=lhours%>" property="hours" sort="true" nulls="true" width="10%"/>
<display:column title="<%=lboughtVol%>" property="boughtVolume" sort="true" nulls="true" width="10%"/>
<display:column title="<%=lsoldVol%>" property="soldVolume" sort="true" nulls="true" width="10%"/>
<display:column title="<%=lnetPosition%>" property="netPosition" sort="true" nulls="true" width="10%"/>
<display:column title="<%=lsettlementPrice%>" property="settlementPrice" sort="true" nulls="true" width="10%"/>
<display:column title="<%=lvaluationParameter%>" property="valuationParameter" sort="true" nulls="true" width="10%"/>
<display:column title="<%=lmarginRequirement%>" property="marginRequirement" sort="true" nulls="true" width="10%"/>
<display:setProperty name="paging.banner.one_item_found" value="" />
<display:setProperty name="paging.banner.all_items_found" value="" />
<display:setProperty name="paging.banner.some_items_found" value="" />
<display:setProperty name="paging.banner.include_first_last" value="false" />
<display:setProperty name="export.amount" value="page" />
<display:setProperty name="export.excel.include_header" value="true" />
<display:setProperty name="paging.banner.group_size" value="6" />
<display:setProperty name="paging.banner.prev_label" value="<%=lback%>" />
<display:setProperty name="paging.banner.next_label" value="<%=lforward%>" />
<display:setProperty name="sort.behavior" value="page" />
</display:table>
</td> </tr>
</table>
-------------
I also use two files (SearchInitialMarginForm.java and SearchInitialMarginAction.java) that has the form and the action from the search).
The problem is:
1. The header on each table should be <bean:write name="initialmargins" property="accountName"/> but I cannot output it (an error occur).
2. I need to output the tables dynamically based on the number of loadProfile there is (in the example it is just two of them (1 and 2)).
I realize this is a fairly complex request, but I would be extremly grateful if anyone could help me solving this.
Thanks a lot, Bard A.
------------------------------------------------------- This SF.Net email sponsored by: Parasoft Error proof Web apps, automate testing & more. Download & eval WebKing and get a free book. www.parasoft.com/bulletproofapps _______________________________________________ displaytag-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/displaytag-user

