voyent
ice:dataTable selected column change event.  XML
Forum Index -> Components
Author Message
vaughn_preddy

Joined: 08/Sep/2008 00:00:00
Messages: 20
Offline


Hi,

I am new to icefaces.
Im currently trying to create a datatable that mimics what excel does.
IE I have ice:inputText that allow the user to change a property on a session bean.

Like in excel some columns are to be a calculated based on other columns e.g. column3 = column2 + 100. The users will enter some data into one column2 and column3 will automattically be updated based on the first column2's information.

I started developing this and ran into a snag.
Below is the code for the datatable

[code]

<ice:form>
<ice:dataTable id="Tbl" value="#{portfolioListBean.portfoliostatementbeans}" var="ps" style="tableStyle" border="1" cellpadding="5" cellspacing="0">
<ice:column id="column1">
<ice:outputText value="#{ps.bankAccountName}"></ice:outputText>
<f:facet name="header">
<ice:outputText value="Bank Name"></ice:outputText>
</f:facet>
</ice:column>
<ice:column id="column2" >
<ice:inputText value="#{ps.availableBalance}" ></ice:inputText>
<f:facet name="header">
<ice:outputText value="Available Balance" ></ice:outputText>
</f:facet>
</ice:column>
<ice:column id="column3">
<ice:inputText value="#{ps.balanceTransfer}"></ice:inputText>
<f:facet name="header">
<ice:outputText value="Balance Transfer"></ice:outputText>
</f:facet>
</ice:column>
</ice:dataTable>
</ice:form>

[/code]

Below we can see the property ps.balanceTransfer will be calculated based on ps.availableBalance this is done in the bean itself

The code for the bean is as follows.
[code]
public class PortfolioStatementBean extends BaseBean{
private PortfolioStatement portfolioStatement;
private String bankAccountName;
[color=darkred]private Double availableBalance;
private Double balanceTransfer;[
public Double getBalanceTransfer() {

return availableBalance +100;
}

public void setBalanceTransfer(Double balanceTransfer) {
this.balanceTransfer = balanceTransfer;
}

public Double getAvailableBalance() {

return availableBalance;
}

public void setAvailableBalance(Double availableBalance) {
this.availableBalance = availableBalance;
}[/color]
public String getBankAccountName() {
return portfolioStatement.getBnkAccount().getBankAccName();
}

public void setBankAccountName(String bankAccountName) {
this.bankAccountName = portfolioStatement.getBnkAccount().getBankAccName();
}

public PortfolioStatement getPortfolioStatement() {
return portfolioStatement;
}

public void setPortfolioStatement(PortfolioStatement portfolioStatement) {
this.portfolioStatement = portfolioStatement;
}


}
[/code]

Please note that portfoliostatmentbean is actually a wrapper for another class portfoliostatement. This class in unimportant regarding the question.


Here is the Faces-config.xml file
[code]
<managed-bean>
<description>Backing bean that wraps portfolioStatement information.</description>
<managed-bean-name>PortfolioStatementBean</managed-bean-name>
<managed-bean-class>view.bean.PortfolioStatementBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
[/code]



Question 1)
By default when I run the application and enter in a value into column2 i.e. ps.availableBalance and I click enter or select a new row
column3 = column2 + 100 as planned. see DataTable3.jpg

Please refer to the screen shots of the application


Unexpectantly if I make a change to column2 and not click enter but more straight to column3 on the same row the value in column2 disapears and column3 is not updated. see DataTable4.jpg

Why is this?
Would I need intercept the column or cell change event so that it mimics the event of a row change click?

Many thanks and regards Vaughn Preddy

[Email]
vaughn_preddy

Joined: 08/Sep/2008 00:00:00
Messages: 20
Offline


Here are the images related to this post
Thanks
[Thumb - DataTable4.JPG]
 Filename DataTable4.JPG [Disk] Download
 Description Then one moves to the adjacent column on the same row the values are reset
 Filesize 90 Kbytes
 Downloaded:  352 time(s)

[Thumb - DataTable3.JPG]
 Filename DataTable3.JPG [Disk] Download
 Description When one moves to a new row the columns are updated correctly
 Filesize 85 Kbytes
 Downloaded:  305 time(s)

[Email]
vaughn_preddy

Joined: 08/Sep/2008 00:00:00
Messages: 20
Offline


I copied the way auction monitor works. IE I used the commandlinks in the inputtext to submit the data and didnt rely on clicking off the cell like excel.
[Email]
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


If the table is not huge you could add partialSubmit="true" to your inputTexts (or to the form if you wish). But this will do a full form submit on each cell navigation (on inputText it's fired by onblur) so make sure your form doesn't have lots of fields, or the user's experience will suffer.

Eduard
 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team