You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by V SANTOSH PAVAN RAJU Bs <pa...@gmail.com> on 2012/10/17 11:57:09 UTC

Adding $ symbol for each cell entry in a tableview

Hi,

Iam trying to get a $ symbol for tableview entries. For this i have used
Stock Tracker demo application and it is working fine. Now I created a
table where columns will be changed from time to time so i have created
tableview, where columns will be added dynamically and by using
setCellRenderer method, i have added TableViewNumberCellRenderer class
object to each tableview column. Here also i was able to get the $ symbol
for each cell entry.

Now iam supposed to create a tableview with columns number is unknown. So i
used HashMap to create rows and to insert data to each cell. So for this
process how can i add TableViewNumberCellRenderer class object. I use the
following code for this purpose.

TableView.Column column = new TableView.Column();
column.setName("number");
column.setWidth(180);
column.setHeaderData("Number");
TableViewNumberCellRenderer cellRenderer = new
TableViewNumberCellRenderer();
column.setCellRenderer(cellRenderer);//
tableView.getColumns().add(column);

HashMap<String, Object> tableData= new HashMap<String, Object>();
tableData.put("column name",null);
// value is null beacuse here i will edit the row and then enter some
 value in it.
((List<Object>) (tableView.getTableData())).add(tableData);

Here in place of null if i pass some value (float type) 4 symbol is
appearing. But when i tried to edit the row $ symbol getting disappeared.
So help me how can i resolve this?

-- 
Thanks & Regards
B.S.V.S.Pavan Raju.
Skype: skype_pavan1
Hyderabad.

Re: Adding $ symbol for each cell entry in a tableview

Posted by Anusha <dh...@gmail.com>.



-----
anusha
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Adding-symbol-for-each-cell-entry-in-a-tableview-tp4022173p4022176.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Adding $ symbol for each cell entry in a tableview

Posted by Sandro Martini <sa...@gmail.com>.
Hi,
> Can you please go through the application, because i was stuck here and it is urgent
Please note that I'm working on Pivot (and after even on this) in my
*free* time and some days are worst than others on this (I have
already setup a test environment and do some checks, but I have to
understand better, so more time is needed), so you have to wait some
day, sorry but can't do better.

Sandro

RE: Adding $ symbol for each cell entry in a tableview

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Thanks, Sandro.  Actually, I think moving the code to a dedicated method
won't be necessary if it does the "right thing" with respect to calling
the renderer and ultimately the formatter.

~Roger

-----Original Message-----
From: Sandro Martini [mailto:sandro.martini@gmail.com] 
Sent: Monday, October 22, 2012 1:40 PM
To: user@pivot.apache.org
Cc: dev@pivot.apache.org
Subject: Re: Adding $ symbol for each cell entry in a tableview

Hi Roger,

> Seems to me like the row editor should do the same thing as the 
> display code (namely calling the renderer, which includes formatting) 
> after storing/retrieving the data.  I would think that should be
sufficient.
>
Ok, I'll try tomorrow (my fear is to generate some loop, but makes sense
in this way), thanks for now.

Do you like the idea to move that small part in a dedicated method (so
anyone want to override it could do it in a simpler way ... if needed) ?


Bye

RE: Adding $ symbol for each cell entry in a tableview

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Thanks, Sandro.  Actually, I think moving the code to a dedicated method
won't be necessary if it does the "right thing" with respect to calling
the renderer and ultimately the formatter.

~Roger

-----Original Message-----
From: Sandro Martini [mailto:sandro.martini@gmail.com] 
Sent: Monday, October 22, 2012 1:40 PM
To: user@pivot.apache.org
Cc: dev@pivot.apache.org
Subject: Re: Adding $ symbol for each cell entry in a tableview

Hi Roger,

> Seems to me like the row editor should do the same thing as the 
> display code (namely calling the renderer, which includes formatting) 
> after storing/retrieving the data.  I would think that should be
sufficient.
>
Ok, I'll try tomorrow (my fear is to generate some loop, but makes sense
in this way), thanks for now.

Do you like the idea to move that small part in a dedicated method (so
anyone want to override it could do it in a simpler way ... if needed) ?


Bye

Re: Adding $ symbol for each cell entry in a tableview

Posted by Sandro Martini <sa...@gmail.com>.
Hi Roger,

> Seems to me like the row editor should do the same thing as the display
> code (namely calling the renderer, which includes formatting) after
> storing/retrieving the data.  I would think that should be sufficient.
>
Ok, I'll try tomorrow (my fear is to generate some loop, but makes
sense in this way), thanks for now.

Do you like the idea to move that small part in a dedicated method (so
anyone want to override it could do it in a simpler way ... if needed)
?


Bye

Re: Adding $ symbol for each cell entry in a tableview

Posted by Sandro Martini <sa...@gmail.com>.
Hi Roger,

> Seems to me like the row editor should do the same thing as the display
> code (namely calling the renderer, which includes formatting) after
> storing/retrieving the data.  I would think that should be sufficient.
>
Ok, I'll try tomorrow (my fear is to generate some loop, but makes
sense in this way), thanks for now.

Do you like the idea to move that small part in a dedicated method (so
anyone want to override it could do it in a simpler way ... if needed)
?


Bye

RE: Adding $ symbol for each cell entry in a tableview

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Seems to me like the row editor should do the same thing as the display
code (namely calling the renderer, which includes formatting) after
storing/retrieving the data.  I would think that should be sufficient.

~Roger Whitcomb

-----Original Message-----
From: Sandro Martini [mailto:sandro.martini@gmail.com] 
Sent: Monday, October 22, 2012 9:18 AM
To: user@pivot.apache.org; Developers - Apache Pivot
Subject: Re: Adding $ symbol for each cell entry in a tableview

Including developers mailing list because there is a small question for
Pivot Developers (but of course comments and suggestions are welcome
from anyone):

after some tests, to me it seems that when the table row editor starts /
ends the edit phase, data is get from the table row and here data lose
its currency formatting.


I have to open a jira issue for this, for 2.0.3.


Just as idea, in TableViewRowEditor, in both methods beginEdit and
endEdit there is a small block of code:

            List<Object> tableData =
(List<Object>)tableView.getTableData();
            Object tableRow = tableData.get(rowIndex);


maybe to simplify, we could think to move this block in a dedicated
method (maybe with an additional argument that say whick event is, if
begin or end), so others could override only this ... to simplify things
for who need this.
Or find a way (but the same inside an overridden version of those
methods) to re-apply the right format at the end of edit.

Otherwise we could at least verify if extending the Pivot class and use
a custom version of both methods, if works as a good workaround, and
move to 2.0.4 ...


A better solution could be to add a listener for this kind of event, and
if there is one, use it ... but maybe this for 2.1 .


Last, a quick workaround (but not-so-good, I know) for the given test
application, could be in CurrencyCellRenderer (the custom cell rendered
of the sample) to extend the else case inside the toString method, and
try to convert to number the given strings and reapply the format, and
call the toString method only as last choice.


What do you think ?


Bye,
Sandro



2012/10/22 Sandro Martini <sa...@gmail.com>:
> Hi all,
> after some tests I think there is some problem in the row editor, 
> because it's true, for example if I use this (inside your example):
>
> SamplePage.java
>                 tableData = new HashMap<String, Float>();
>                     tableData.put(Integer.toString(i), new Float(i + 
> 0.5));  // test with this the first time currency symbol is show in 
> any cell (the same replacing Float with Integer)
>
> first time:
> CurrencyCellRenderer: cellData = 0.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 1.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 2.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 3.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 4.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 5.5
>
>
> but after editing a row, it disappears ... and cell contents are no 
> more instanceof Number .
>
> Using this instead:
> //                rowEditor.getCellEditors().put(Integer.toString(i),
> textInput);
>                 rowEditor.getCellEditors().put(Integer.toString(i), 
> null); you are not able to edit cell contents, but the format of 
> strings is good even after the tentative edit.
> And last, using a TextArea instead gives another result ...
>
>
> Probably there is something in TableViewRowEditor to fix or to extend.
>
> In the meantime you can try adding a custom version of row editor, 
> with support for currency columns.
>
>
> A fix for this must go in 2.0.3.
> But first I have to look at it  better ... at least if/how there is a 
> good workaround (could be to extend row editor).
>
>
> Let's update,
> Sandro

RE: Adding $ symbol for each cell entry in a tableview

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Seems to me like the row editor should do the same thing as the display
code (namely calling the renderer, which includes formatting) after
storing/retrieving the data.  I would think that should be sufficient.

~Roger Whitcomb

-----Original Message-----
From: Sandro Martini [mailto:sandro.martini@gmail.com] 
Sent: Monday, October 22, 2012 9:18 AM
To: user@pivot.apache.org; Developers - Apache Pivot
Subject: Re: Adding $ symbol for each cell entry in a tableview

Including developers mailing list because there is a small question for
Pivot Developers (but of course comments and suggestions are welcome
from anyone):

after some tests, to me it seems that when the table row editor starts /
ends the edit phase, data is get from the table row and here data lose
its currency formatting.


I have to open a jira issue for this, for 2.0.3.


Just as idea, in TableViewRowEditor, in both methods beginEdit and
endEdit there is a small block of code:

            List<Object> tableData =
(List<Object>)tableView.getTableData();
            Object tableRow = tableData.get(rowIndex);


maybe to simplify, we could think to move this block in a dedicated
method (maybe with an additional argument that say whick event is, if
begin or end), so others could override only this ... to simplify things
for who need this.
Or find a way (but the same inside an overridden version of those
methods) to re-apply the right format at the end of edit.

Otherwise we could at least verify if extending the Pivot class and use
a custom version of both methods, if works as a good workaround, and
move to 2.0.4 ...


A better solution could be to add a listener for this kind of event, and
if there is one, use it ... but maybe this for 2.1 .


Last, a quick workaround (but not-so-good, I know) for the given test
application, could be in CurrencyCellRenderer (the custom cell rendered
of the sample) to extend the else case inside the toString method, and
try to convert to number the given strings and reapply the format, and
call the toString method only as last choice.


What do you think ?


Bye,
Sandro



2012/10/22 Sandro Martini <sa...@gmail.com>:
> Hi all,
> after some tests I think there is some problem in the row editor, 
> because it's true, for example if I use this (inside your example):
>
> SamplePage.java
>                 tableData = new HashMap<String, Float>();
>                     tableData.put(Integer.toString(i), new Float(i + 
> 0.5));  // test with this the first time currency symbol is show in 
> any cell (the same replacing Float with Integer)
>
> first time:
> CurrencyCellRenderer: cellData = 0.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 1.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 2.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 3.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 4.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 5.5
>
>
> but after editing a row, it disappears ... and cell contents are no 
> more instanceof Number .
>
> Using this instead:
> //                rowEditor.getCellEditors().put(Integer.toString(i),
> textInput);
>                 rowEditor.getCellEditors().put(Integer.toString(i), 
> null); you are not able to edit cell contents, but the format of 
> strings is good even after the tentative edit.
> And last, using a TextArea instead gives another result ...
>
>
> Probably there is something in TableViewRowEditor to fix or to extend.
>
> In the meantime you can try adding a custom version of row editor, 
> with support for currency columns.
>
>
> A fix for this must go in 2.0.3.
> But first I have to look at it  better ... at least if/how there is a 
> good workaround (could be to extend row editor).
>
>
> Let's update,
> Sandro

Re: Adding $ symbol for each cell entry in a tableview

Posted by Sandro Martini <sa...@gmail.com>.
Including developers mailing list because there is a small question
for Pivot Developers (but of course comments and suggestions are
welcome from anyone):

after some tests, to me it seems that when the table row editor starts
/ ends the edit phase, data is get from the table row and here data
lose its currency formatting.


I have to open a jira issue for this, for 2.0.3.


Just as idea, in TableViewRowEditor, in both methods beginEdit and
endEdit there is a small block of code:

            List<Object> tableData = (List<Object>)tableView.getTableData();
            Object tableRow = tableData.get(rowIndex);


maybe to simplify, we could think to move this block in a dedicated
method (maybe with an additional argument that say whick event is, if
begin or end), so others could override only this ... to simplify
things for who need this.
Or find a way (but the same inside an overridden version of those
methods) to re-apply the right format at the end of edit.

Otherwise we could at least verify if extending the Pivot class and
use a custom version of both methods, if works as a good workaround,
and move to 2.0.4 ...


A better solution could be to add a listener for this kind of event,
and if there is one, use it ... but maybe this for 2.1 .


Last, a quick workaround (but not-so-good, I know) for the given test
application, could be in CurrencyCellRenderer (the custom cell
rendered of the sample) to extend the else case inside the toString
method, and try to convert to number the given strings and reapply the
format, and call the toString method only as last choice.


What do you think ?


Bye,
Sandro



2012/10/22 Sandro Martini <sa...@gmail.com>:
> Hi all,
> after some tests I think there is some problem in the row editor,
> because it's true, for example if I use this (inside your example):
>
> SamplePage.java
>                 tableData = new HashMap<String, Float>();
>                     tableData.put(Integer.toString(i), new Float(i +
> 0.5));  // test
> with this the first time currency symbol is show in any cell
> (the same replacing Float with Integer)
>
> first time:
> CurrencyCellRenderer: cellData = 0.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 1.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 2.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 3.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 4.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 5.5
>
>
> but after editing a row, it disappears ... and cell contents are no
> more instanceof Number .
>
> Using this instead:
> //                rowEditor.getCellEditors().put(Integer.toString(i),
> textInput);
>                 rowEditor.getCellEditors().put(Integer.toString(i), null);
> you are not able to edit cell contents, but the format of strings is
> good even after the tentative edit.
> And last, using a TextArea instead gives another result ...
>
>
> Probably there is something in TableViewRowEditor to fix or to extend.
>
> In the meantime you can try adding a custom version of row editor,
> with support for currency columns.
>
>
> A fix for this must go in 2.0.3.
> But first I have to look at it  better ... at least if/how there is a
> good workaround (could be to extend row editor).
>
>
> Let's update,
> Sandro

Re: Adding $ symbol for each cell entry in a tableview

Posted by Sandro Martini <sa...@gmail.com>.
Including developers mailing list because there is a small question
for Pivot Developers (but of course comments and suggestions are
welcome from anyone):

after some tests, to me it seems that when the table row editor starts
/ ends the edit phase, data is get from the table row and here data
lose its currency formatting.


I have to open a jira issue for this, for 2.0.3.


Just as idea, in TableViewRowEditor, in both methods beginEdit and
endEdit there is a small block of code:

            List<Object> tableData = (List<Object>)tableView.getTableData();
            Object tableRow = tableData.get(rowIndex);


maybe to simplify, we could think to move this block in a dedicated
method (maybe with an additional argument that say whick event is, if
begin or end), so others could override only this ... to simplify
things for who need this.
Or find a way (but the same inside an overridden version of those
methods) to re-apply the right format at the end of edit.

Otherwise we could at least verify if extending the Pivot class and
use a custom version of both methods, if works as a good workaround,
and move to 2.0.4 ...


A better solution could be to add a listener for this kind of event,
and if there is one, use it ... but maybe this for 2.1 .


Last, a quick workaround (but not-so-good, I know) for the given test
application, could be in CurrencyCellRenderer (the custom cell
rendered of the sample) to extend the else case inside the toString
method, and try to convert to number the given strings and reapply the
format, and call the toString method only as last choice.


What do you think ?


Bye,
Sandro



2012/10/22 Sandro Martini <sa...@gmail.com>:
> Hi all,
> after some tests I think there is some problem in the row editor,
> because it's true, for example if I use this (inside your example):
>
> SamplePage.java
>                 tableData = new HashMap<String, Float>();
>                     tableData.put(Integer.toString(i), new Float(i +
> 0.5));  // test
> with this the first time currency symbol is show in any cell
> (the same replacing Float with Integer)
>
> first time:
> CurrencyCellRenderer: cellData = 0.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 1.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 2.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 3.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 4.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 5.5
>
>
> but after editing a row, it disappears ... and cell contents are no
> more instanceof Number .
>
> Using this instead:
> //                rowEditor.getCellEditors().put(Integer.toString(i),
> textInput);
>                 rowEditor.getCellEditors().put(Integer.toString(i), null);
> you are not able to edit cell contents, but the format of strings is
> good even after the tentative edit.
> And last, using a TextArea instead gives another result ...
>
>
> Probably there is something in TableViewRowEditor to fix or to extend.
>
> In the meantime you can try adding a custom version of row editor,
> with support for currency columns.
>
>
> A fix for this must go in 2.0.3.
> But first I have to look at it  better ... at least if/how there is a
> good workaround (could be to extend row editor).
>
>
> Let's update,
> Sandro

Re: Adding $ symbol for each cell entry in a tableview

Posted by Sandro Martini <sa...@gmail.com>.
Hi all,
after some tests I think there is some problem in the row editor,
because it's true, for example if I use this (inside your example):

SamplePage.java
                tableData = new HashMap<String, Float>();
                    tableData.put(Integer.toString(i), new Float(i +
0.5));  // test
with this the first time currency symbol is show in any cell
(the same replacing Float with Integer)

first time:
CurrencyCellRenderer: cellData = 0.5
CurrencyCellRenderer: cellData instanceof Number = true
CurrencyCellRenderer: cellData = 1.5
CurrencyCellRenderer: cellData instanceof Number = true
CurrencyCellRenderer: cellData = 2.5
CurrencyCellRenderer: cellData instanceof Number = true
CurrencyCellRenderer: cellData = 3.5
CurrencyCellRenderer: cellData instanceof Number = true
CurrencyCellRenderer: cellData = 4.5
CurrencyCellRenderer: cellData instanceof Number = true
CurrencyCellRenderer: cellData = 5.5


but after editing a row, it disappears ... and cell contents are no
more instanceof Number .

Using this instead:
//                rowEditor.getCellEditors().put(Integer.toString(i),
textInput);
		rowEditor.getCellEditors().put(Integer.toString(i), null);
you are not able to edit cell contents, but the format of strings is
good even after the tentative edit.
And last, using a TextArea instead gives another result ...


Probably there is something in TableViewRowEditor to fix or to extend.

In the meantime you can try adding a custom version of row editor,
with support for currency columns.


A fix for this must go in 2.0.3.
But first I have to look at it  better ... at least if/how there is a
good workaround (could be to extend row editor).


Let's update,
Sandro

Re: Adding $ symbol for each cell entry in a tableview

Posted by Chris Bartlett <cb...@gmail.com>.
Santosh,

Firstly, please remember that Sandro and others on this mailing list
are volunteers providing free assistance when they can.

I haven't run your code, but I would suggest looking at the your
CurrencyCellRenderer.toString(Object, String) method based on the last
line of your original email.   Is cellData an instance of Number?  If
not, it wont get any special formatting.
The method tries to format a Number using 'numberFormat' or convert to
a String otherwise.  When the cell values are null, the toString
method returns null.  If the cell value is a non-null, non-Number the
object's own toString() method is called.   My guess is that cellData
is either null or a String when you are not seeing the formatted
result you expected.

Chris


On 20 October 2012 15:02, Santosh <pa...@gmail.com> wrote:
> Hi Sandro,
> Can you please go through the application, because i was stuck here and it
> is urgent
>
> On Thu, Oct 18, 2012 at 2:20 PM, Sandro Martini [via Apache Pivot - Users]
> <[hidden email]> wrote:
>>
>> Hi,
>> I'll take a look in next days ... thanks for now.
>>
>> Sandro
>>
>>
>> ________________________________
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://apache-pivot-users.399431.n3.nabble.com/Adding-symbol-for-each-cell-entry-in-a-tableview-tp4022173p4022180.html
>> To unsubscribe from Adding $ symbol for each cell entry in a tableview,
>> click here.
>> NAML
>
>
>
>
> --
> Thanks & Regards
> B.S.V.S.Pavan Raju.
> Skype: skype_pavan1
> Hyderabad.
>
> santosh pavan raju
>
> ________________________________
> View this message in context: Re: Adding $ symbol for each cell entry in a
> tableview
>
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Adding $ symbol for each cell entry in a tableview

Posted by Santosh <pa...@gmail.com>.
Hi Sandro,
Can you please go through the application, because i was stuck here and it
is urgent

On Thu, Oct 18, 2012 at 2:20 PM, Sandro Martini [via Apache Pivot - Users] <
ml-node+s399431n4022180h46@n3.nabble.com> wrote:

> Hi,
> I'll take a look in next days ... thanks for now.
>
> Sandro
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-pivot-users.399431.n3.nabble.com/Adding-symbol-for-each-cell-entry-in-a-tableview-tp4022173p4022180.html
>  To unsubscribe from Adding $ symbol for each cell entry in a tableview, click
> here<http://apache-pivot-users.399431.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4022173&code=cGF2YW5yYWp1Lm1jYUBnbWFpbC5jb218NDAyMjE3M3w2MjIwNTU2NTA=>
> .
> NAML<http://apache-pivot-users.399431.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Thanks & Regards
B.S.V.S.Pavan Raju.
Skype: skype_pavan1
Hyderabad.




-----
santosh pavan raju
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Adding-symbol-for-each-cell-entry-in-a-tableview-tp4022173p4022181.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Adding $ symbol for each cell entry in a tableview

Posted by Sandro Martini <sa...@gmail.com>.
Hi,
I'll take a look in next days ... thanks for now.

Sandro

Re: Adding $ symbol for each cell entry in a tableview

Posted by Santosh <pa...@gmail.com>.
SampleApplication.rar
<http://apache-pivot-users.399431.n3.nabble.com/file/n4022177/SampleApplication.rar>  
Hi Sandro, 
This is a sample application in which one table was created with some some
columns and i used CurrencyCellRenderer class to get a $ symbol for each
cell entry.
Please go through this one and let me know where i was wrong.



-----
santosh pavan raju
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Adding-symbol-for-each-cell-entry-in-a-tableview-tp4022173p4022177.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Adding $ symbol for each cell entry in a tableview

Posted by Sandro Martini <sa...@gmail.com>.
Hi,
could be something related to your table row editor ...

If you have a miniaml sample please post here so we can look better at this.

Bye

Re: Adding $ symbol for each cell entry in a tableview

Posted by Sandro Martini <sa...@gmail.com>.
Sorry, just found a sample for this (so no additional one is required):

look into the package demos/org.apache.pivot.demos.roweditor

The sample must start by running RowEditorDemo.java (otherwise
resources/labels won't be resolved in the right way), and in related
files you can find a currency formatting with the TableViewRowEditor
and TextInput.TextBindMapping .


I think that for this now that's all.

Bye

Re: Adding $ symbol for each cell entry in a tableview

Posted by Sandro Martini <sa...@gmail.com>.
Sorry, just found a sample for this (so no additional one is required):

look into the package demos/org.apache.pivot.demos.roweditor

The sample must start by running RowEditorDemo.java (otherwise
resources/labels won't be resolved in the right way), and in related
files you can find a currency formatting with the TableViewRowEditor
and TextInput.TextBindMapping .


I think that for this now that's all.

Bye

Re: Adding $ symbol for each cell entry in a tableview

Posted by Sandro Martini <sa...@gmail.com>.
Hi all,

Roger, thank you very much for the help.

If possible I'll try in next days (but probably next week) to put
under the tests subproject a minimal sample for this (but could go
into 2.0.4) ...

Bye,
Sandro

Re: Adding $ symbol for each cell entry in a tableview

Posted by Sandro Martini <sa...@gmail.com>.
Hi all,

Roger, thank you very much for the help.

If possible I'll try in next days (but probably next week) to put
under the tests subproject a minimal sample for this (but could go
into 2.0.4) ...

Bye,
Sandro

RE: Adding $ symbol for each cell entry in a tableview

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Okay, after looking at this some more, I think the fundamental problem
boils down to how the cell editor is implemented for the number column
in the TableViewRowEditor that you are using.  In the "endEdit" method
of TableViewRowEditor, it will call "store" for each column in the
editor to put the edited value back into the row object (this is the
code that Sandro highlighted in the earlier reply).  Normally you would
probably use a TextInput for the edit field, but TextInput.store changes
the text in the control to the proper object for storing based on the
TextBindMapping that is defined.  If there is no binding, then it will
be a String that is stored in your row HashMap and then the
TableViewNumberCellRenderer will not put a $ in the data because it only
does that for the Number types.

 

So, what you need to do is define a small class that implements
TextInput.TextBindMapping, then set an instance of that as the
TextBindMapping for the cell editor used for the TableViewRowEditor.....
The "valueOf(String text)" method of your class would strip off the $
sign and convert the result to a Number..... That will solve your
problem and Pivot doesn't need to change - the functionality you need is
already built in.

 

HTH,

~Roger Whitcomb

 

From: V SANTOSH PAVAN RAJU Bs [mailto:pavanraju.mca@gmail.com] 
Sent: Wednesday, October 17, 2012 2:57 AM
To: user@pivot.apache.org
Subject: Adding $ symbol for each cell entry in a tableview

 

Hi,

 

Iam trying to get a $ symbol for tableview entries. For this i have used
Stock Tracker demo application and it is working fine. Now I created a
table where columns will be changed from time to time so i have created
tableview, where columns will be added dynamically and by using
setCellRenderer method, i have added TableViewNumberCellRenderer class
object to each tableview column. Here also i was able to get the $
symbol for each cell entry.

 

Now iam supposed to create a tableview with columns number is unknown.
So i used HashMap to create rows and to insert data to each cell. So for
this process how can i add TableViewNumberCellRenderer class object. I
use the following code for this purpose.

 

TableView.Column column = new TableView.Column();
column.setName("number");
column.setWidth(180);
column.setHeaderData("Number");

TableViewNumberCellRenderer cellRenderer = new
TableViewNumberCellRenderer();
column.setCellRenderer(cellRenderer);//                                
tableView.getColumns().add(column);

HashMap<String, Object> tableData= new HashMap<String, Object>();
tableData.put("column name",null);

// value is null beacuse here i will edit the row and then enter some
value in it.
((List<Object>) (tableView.getTableData())).add(tableData);

 

Here in place of null if i pass some value (float type) 4 symbol is
appearing. But when i tried to edit the row $ symbol getting
disappeared. So help me how can i resolve this?

 

-- 
Thanks & Regards

B.S.V.S.Pavan Raju.

Skype: skype_pavan1

Hyderabad.

 


RE: Adding $ symbol for each cell entry in a tableview

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Okay, after looking at this some more, I think the fundamental problem
boils down to how the cell editor is implemented for the number column
in the TableViewRowEditor that you are using.  In the "endEdit" method
of TableViewRowEditor, it will call "store" for each column in the
editor to put the edited value back into the row object (this is the
code that Sandro highlighted in the earlier reply).  Normally you would
probably use a TextInput for the edit field, but TextInput.store changes
the text in the control to the proper object for storing based on the
TextBindMapping that is defined.  If there is no binding, then it will
be a String that is stored in your row HashMap and then the
TableViewNumberCellRenderer will not put a $ in the data because it only
does that for the Number types.

 

So, what you need to do is define a small class that implements
TextInput.TextBindMapping, then set an instance of that as the
TextBindMapping for the cell editor used for the TableViewRowEditor.....
The "valueOf(String text)" method of your class would strip off the $
sign and convert the result to a Number..... That will solve your
problem and Pivot doesn't need to change - the functionality you need is
already built in.

 

HTH,

~Roger Whitcomb

 

From: V SANTOSH PAVAN RAJU Bs [mailto:pavanraju.mca@gmail.com] 
Sent: Wednesday, October 17, 2012 2:57 AM
To: user@pivot.apache.org
Subject: Adding $ symbol for each cell entry in a tableview

 

Hi,

 

Iam trying to get a $ symbol for tableview entries. For this i have used
Stock Tracker demo application and it is working fine. Now I created a
table where columns will be changed from time to time so i have created
tableview, where columns will be added dynamically and by using
setCellRenderer method, i have added TableViewNumberCellRenderer class
object to each tableview column. Here also i was able to get the $
symbol for each cell entry.

 

Now iam supposed to create a tableview with columns number is unknown.
So i used HashMap to create rows and to insert data to each cell. So for
this process how can i add TableViewNumberCellRenderer class object. I
use the following code for this purpose.

 

TableView.Column column = new TableView.Column();
column.setName("number");
column.setWidth(180);
column.setHeaderData("Number");

TableViewNumberCellRenderer cellRenderer = new
TableViewNumberCellRenderer();
column.setCellRenderer(cellRenderer);//                                
tableView.getColumns().add(column);

HashMap<String, Object> tableData= new HashMap<String, Object>();
tableData.put("column name",null);

// value is null beacuse here i will edit the row and then enter some
value in it.
((List<Object>) (tableView.getTableData())).add(tableData);

 

Here in place of null if i pass some value (float type) 4 symbol is
appearing. But when i tried to edit the row $ symbol getting
disappeared. So help me how can i resolve this?

 

-- 
Thanks & Regards

B.S.V.S.Pavan Raju.

Skype: skype_pavan1

Hyderabad.