Hi,
I have two selectitems. One depicting the month and other year. Both need to be fetched from database depending on what months user have subscribed.
I have a datasource which have two fetch operations one to fetch list of years and the other to fetch the months available for one of the years in the year selectitem. The rows are very minimal, not more than 10 and I would want it to funtion as local. I haven't implemented the other functionality like changing the months when year changes etc.
I see when I initially fetch available years to populate the year selectitem and then fetch available months for one of the year in the months selectiem, but when I try using the year dropdown and then try using month dropdown it goes for another fetch operation. It keeps happening while I try between these components. Using one causes other to make a fresh fetch request.
Can somebody demistify why this behavior.
DS.XML FILE
THANKS.
I have two selectitems. One depicting the month and other year. Both need to be fetched from database depending on what months user have subscribed.
I have a datasource which have two fetch operations one to fetch list of years and the other to fetch the months available for one of the years in the year selectitem. The rows are very minimal, not more than 10 and I would want it to funtion as local. I haven't implemented the other functionality like changing the months when year changes etc.
I see when I initially fetch available years to populate the year selectitem and then fetch available months for one of the year in the months selectiem, but when I try using the year dropdown and then try using month dropdown it goes for another fetch operation. It keeps happening while I try between these components. Using one causes other to make a fresh fetch request.
Can somebody demistify why this behavior.
Code:
final SelectItem fromYear = new SelectItem(); final SelectItem fromMonth = new SelectItem(); fromYear.setName("fromYear"); fromYear.setTitle("From"); fromYear.setDefaultToFirstOption(true); fromYear.setWidth(75); fromYear.setWrapTitle(false); fromYear.setColSpan(1); fromYear.setOptionDataSource(DataSource.get("dateRange")); fromYear.setOptionOperationId("dateRangeYear"); fromYear.setValueField("YEAR_NUM"); fromYear.setFilterLocally(true); fromMonth.setName("fromMonth"); fromMonth.setShowTitle(false); fromMonth.setType("comboBox"); fromMonth.setWidth(75); fromMonth.setDefaultToFirstOption(true); fromMonth.setWrapTitle(false); fromMonth.setColSpan(1); fromMonth.setOptionDataSource(DataSource.get("dateRange")); fromMonth.setOptionOperationId("dateRangeMonth"); fromMonth.setValueField("MONTH_SHORT_NAME"); fromMonth.setFilterLocally(true);
Code:
<DataSource ID="dateRange" table="CLIENT_VALID_DATES" serverType="sql" dbName="Oracle" showPrompt="false" qualifyColumnNames="false"> <fields> <field name="CLIENT_ID" type="number" required="false" title="CLIENT_ID"/> <field name="YEAR_NUM" type="number" required="true" title="YEAR_NUM"/> <field name="MONTH_NUM" type="number" required="false" title="MONTH_NUM"/> <field name="MONTH_SHORT_NAME" type="text" required="false" title="MONTH_SHORT_NAME"/> <field name="MONTH_ID" type="number" required="false" title="MONTH_ID"/> <field name="QUARTER_ID" type="number" required="false" title="QUARTER_ID"/> <field name="PRODUCT_ID" type="text" required="false" title="PRODUCT_ID"/> </fields> <operationBindings> <operationBinding operationType="fetch" operationId="dateRangeYear"> <selectClause> DISTINCT YEAR_NUM </selectClause> <tableClause> CLIENT_VALID_DATES </tableClause> <whereClause> CLIENT_ID=99 and PRODUCT_ID='NA_ADB' </whereClause> <orderClause> YEAR_NUM DESC </orderClause> </operationBinding> <operationBinding operationType="fetch" operationId="dateRangeMonth"> <selectClause> DISTINCT MONTH_NUM,MONTH_SHORT_NAME </selectClause> <tableClause> CLIENT_VALID_DATES </tableClause> <whereClause> CLIENT_ID=99 and PRODUCT_ID='NA_ADB' AND YEAR_NUM=2011 </whereClause> <orderClause> MONTH_NUM ASC </orderClause> </operationBinding> </operationBindings> </DataSource>
Comment