Converting arrayCollection values into String
Hi,
In my application, the dataprovider of a datagrid which is an arraycollection receives values of objects. I need to get them as string variable so as to convert a particular column in the arraycollection as a string variable of comma seperated values.
I am not too good with flex. Can someone please help me..?
I have three AS classes :
First Class
package script.vo
public class SectorsVO
public function SectorsVO()
public var sectorId:Number;
public var sectorName:String;
public var fromStation:StationsVO;
public var toStation:StationsVO;
Second class
package script.vo
public class StationsVO
public function StationsVO()
public var stationCode:String;
public var stationName:String;
public var countryCode:CountryVO;
Third class
package script.vo
public class CountryVO
public function CountryVO()
public var countryCode:String;
public var countryName:String;
My mxml page is :
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid- controls/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="horizontal"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
import script.vo.SectorsVO;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
[Bindable]
public var sectors:ArrayCollection = new ArrayCollection([{sectorId:101,fromStation:"Calicut",toStation:"Muscat"},
{sectorId:102,fromStation:"Kochi",toStation:"Sharjah"},
{sectorId:103,fromStation:"Bangalore",toStation:"Dubai"},
{sectorId:104,fromStation:"Dubai",toStation:"Amman"},
{sectorId:105,fromStation:"Amman",toStation:"Frankfurt"}]);
[Bindable]
public var draggedSectors:ArrayCollection = new ArrayCollection();
public var mySectors:SectorsVO = new SectorsVO;
public var myString:String = "";
private function getValuesAsCSV():void{
for(var i:int = 0; i < draggedSectors.length; ++i){
mySectors = SectorsVO(draggedSectors.getItemAt(i));
Alert.show("Value is : "+mySectors.sectorId);
myString = String(mySectors.fromStation.stationName);
Alert.show("Sector name :"+myString);
]]>
</mx:Script>
<mx:VBox width="50%">
<mx:Label text="Stations" />
<mx:DataGrid id="dataGrid1" width="100%" rowHeight="22" dataProvider="{sectors}" dragEnabled="true" dragMoveEnabled="true"
dropEnabled="true" verticalScrollPolicy="on">
<mx:columns>
<mx:DataGridColumn dataField="fromStation" headerText="From Station" />
<mx:DataGridColumn dataField="toStation" headerText="To Station" />
</mx:columns>
</mx:DataGrid>
<mx:Label text="{dataGrid1.dataProvider.length} items" />
</mx:VBox>
<mx:VBox width="50%">
<mx:Label text="DataGrid #2" />
<mx:DataGrid id="dataGrid2" width="100%" rowHeight="22" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true"
verticalScrollPolicy="on" dataProvider="{draggedSectors}" >
<mx:columns>
<mx:DataGridColumn dataField="fromStation" headerText="From Station" />
<mx:DataGridColumn dataField="toStation" headerText="To Station" />
</mx:columns>
</mx:DataGrid>
<mx:Label text="{dataGrid2.dataProvider.length} items" />
<mx:Button id="getValues" click="getValuesAsCSV()" label="Get Sectors" enabled="{dataGrid2.dataProvider.length>0}"/>
</mx:VBox>
</mx:Application>
My prime issue is to convert the values in the arraycollection into String variables.
Please help me on the ablve matter..! Thanks in advance..!
fromStation and toStation are already Strings, but you are attempting to cast an ArrayCollection entry to a SectorsVO object. The problem is that SectorsVO has a no-arg constructor and the entry that you are attemping to cast is not of type SectorsVO. You need to modify the constructor to accept an Object and manually assign values to the properties.
It sounds like you are trying to build a CSV string out of all of the values of one of the fields. What you can do is loop through the draggedSectors and pull out the desired property, placing it into a temporary Array. After the loop, simply use Array.join(",") to produce a CSV string.
Similar Messages
-
How to convert BLOB data into string format.
Hi,
I have problem while converting blob data into string format.
for example,
Select dbms_lob.substr(c.shape.Get_wkb(),4000,1) from geotable c
will get me the first 4000 byte of BLOB .
When i using SQL as i did above,the max length is 4000, but i can get 32K using plsql as below:
declare
my_var CLOB;
BEGIN
for x in (Select X from T)
loop
my_var:=dbms_lob.substr(x.X,32767,1)
end loop
return my_var;
I comfortably convert 32k BLOB field to string.
My problem is how to convert blob to varchar having size more than 32K.
Please help me to resolve this,
Thanx in advance for the support,
NileshNilesh,
. . . .The result of get_wkb() will not be human readable (all values are encoded into some binary format).
SELECT utl_raw.cast_to_varchar2(tbl.geometry.get_wkt()) from FeatureTable tbl;
-- resulting string:
☺AW(⌂özßHAA
Å\(÷. . . .You may also want to have a look at { dbms_lob | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i1015792 } "The DBMS_LOB package provides subprograms to operate on BLOBs, CLOBs, NCLOBs, BFILEs, and temporary LOBs."
Regards,
Noel -
Convert given value into words
i want convert given value into words
such as
amount 54300
in words fifty four thousand three hundred only
thanking you
aamirnumber value in words
-
IPhone SDK: How to convert Pixel values into Point values
UIScrollView has a property called contentSize. This takes values in points. How do i convert Pixel values into Point Vales?
-TRSAs far as I can tell, they're the same - I know they are in Photoshop at least. My 57x57 point Tab Bar icon is also 57x57 pixels.
Hope that helps -
How to convert xslt file into string
i'm writting a java program to use xslt to transform the xml file. i'm encountering the problem when i try to convert the xslt file into string. i've defined my utility class called 'XmlUtil' to carry out the operation of transform xml file through xslt. but in my main java program i need to convert both xml and xslt file into a string in order to input them in my function argument. my function argument is as follows:
String htmlString = XmlUtil.applyXsltString(xmlContent, xsltString);
i've already converted xmlcontent into string by using:
xmlContent = xmlContentBuffer.toString();
but i don't know how to convert 'xsltString' now ? i've searched the google for an hour but i cannot find the solution. anyone can help ?
detail of my souce code is as follow:
import java.io.*;
import java.net.*;
import java.lang.*;
import java.io.StringReader;
import java.lang.reflect.Array;
import java.util.Properties;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamSource;
import org.apache.xml.serializer.OutputPropertiesFactory;
import org.apache.xml.serializer.Serializer;
import org.apache.xml.serializer.SerializerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import XmlUtil;
public class FileDownload {
public static void download(String address, String localFileName){
OutputStream out = null;
URLConnection conn = null;
InputStream in = null;
StringBuffer xmlContentBuffer = new StringBuffer();
String temp = new String();
String xmlContent;
try {
URL url = new URL(address);
out = new BufferedOutputStream(
new FileOutputStream(localFileName));
conn = url.openConnection();
in = conn.getInputStream();
byte[] buffer = new byte[1024];
int numRead;
long numWritten = 0;
System.out.println (in.toString ());
while ((numRead = in.read(buffer)) != -1) {
out.write(buffer, 0, numRead);
numWritten += numRead;
temp = new String(buffer);
xmlContentBuffer.append(temp);
System.out.println(localFileName + "\t" + numWritten);
xmlContent = xmlContentBuffer.toString();
String htmlString = XmlUtil.applyXsltString(xmlContent, xsltString);
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (in != null) {
in.close();
if (out != null) {
out.close();
} catch (IOException ioe) {
public static void download(String address) {
int lastSlashIndex = address.lastIndexOf('/');
if (lastSlashIndex >= 0 &&
lastSlashIndex < address.length() - 1) {
download(address, address.substring(lastSlashIndex + 1));
} else {
System.err.println("Could not figure out local file name for " + address);
public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
download(args);
}I don't understand why you need load the XML and XLS files into a String. A Transformer can be constructed from a Source and there is a StreamSouce which can be constructed from an InputStream. The transform() method can take a Source as input and can produce a Result. There is no need to go near a String representation of either the input.
-
How to convert ascii codes into Strings
Is it possible to convert integers (ascii codes) into Strings. It cannot be done by casting like:
int temp = (String)(111)
Please help me out. I think there is a method for this.Something as simple as String.valueOf((char) 111) comes to mind...
-
Convert column values into a row with a delimiter
Hi Gurus,
This may be a trivial question to you. I have an internal table itab with a column called plant, internal table has 'n' records, by the end of loop, I need to convert the column into a row delimited by comma into one row (one field). This needs to be dynamic without hard-coding.
Plant
1000
2000
3000
4000
5000 ....
n....
Expected result of the field:
field1 value: 1000,2000,3000,4000,5000,...n
Let's set a limit to the field say it can hold upto 500 chars.
Thanks,
GP.Hi,
I've already tried this:
ELSEIF <fs_dms_cv>-zca_cv_attr_ind = c_multiple.
w_plant = <fs_plant_ele>-werks.
concatenate w_string w_plant
into w_string separated by c_delimiter.
IF w_end_fl = c_on.
w_tabname = <fs_dms_cv>-dbtabname.
ASSIGN (w_tabname) TO <fs_tabname>.
IF sy-subrc = 0.
ASSIGN COMPONENT <fs_dms_cv>-name_komp OF
STRUCTURE <fs_tabname> TO <fs_destination>.
IF sy-subrc = 0.
<fs_destination> = w_string.
ENDIF.
ENDIF.
There are 2 issues here: One is that after first plant there will be two commas inserted, after that it's consistent. Secondly the key word concatenate is against our code standards.
Please let me know if there is any other way of doing this.
Thanks. -
Converting PrintWriter output into String
Hi All,
i am trying to convert the formatted output got by calling the PrintWriter.println(); method into a string, can anybody suggest how i can do this.
any help is appreciated
Thanks
ManuPls find attached the source code, it will only compile if the jmgmt jar file is present, but i have included the comments telling where i am getting stuck
Thanks a lot
Manu
public
class
SnmpGetRequest
public static void main( String[] args )
PrintWriter out = new PrintWriter( System.out );
SnmpPeer peer = new SnmpPeer( "localhost",
InetAddress.getByName(
"10.1.40.120" ), SMI.PUBLIC );
SnmpConnection connection = new SnmpConnection
( peer );
Vector varbinds = new Vector();
for( int i=0; i<args.length; i++ )
OID oid = new OID( args[ i ] );
varbinds.addElement( oid );
try
Varbind[] result = connection.getRequest( varbinds );
if( result == null )
out.println( " There is no Response from the device " );
else
for( int i = 0; i < result.length; i++ )
result[ i ].print( out );
out.println();//this is where display to screen happens, and this is where i want to catch the display into a string so i can retrieve the value.
catch( SnmpException e )
out.println( e.getMessage());
out.close(); -
How do you convert numeric values into english words?
I am interested in creating a field in adobe acrobat that references a total dollar amount field. I want the java script to convert the numeric number into a written word, such as $59.59 as Fifty Nine and 59/100. I have no experience writing java script code and would really like some help on how this can get done. Its also important to embed in the programming that if their is no numeric value to reference, then nothing get referenced. This means an empty text box. Thanks for any help.
Im using the below script...... I'm a complete novice at this and helping a friend out with it.
Any info is appreciated.
aTens = [ "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
aOnes = [ "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",
"Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen",
"Nineteen" ];
function ConvertToHundreds(num)
var cNum, nNum;
var cWords = "";
num %= 1000;
if (num > 99) {
/* Hundreds. */
cNum = String(num);
nNum = Number(cNum.charAt(0));
cWords += aOnes[nNum] + " Hundred";
num %= 100;
if (num > 0)
cWords += " and "
if (num > 19) {
/* Tens. */
cNum = String(num);
nNum = Number(cNum.charAt(0));
cWords += aTens[nNum - 2];
num %= 10;
if (num > 0)
cWords += "-";
if (num > 0) {
/* Ones and teens. */
nNum = Math.floor(num);
cWords += aOnes[nNum];
return cWords;
function ConvertToWords(num)
var aUnits = [ "Thousand", "Million", "Billion", "Trillion", "Quadrillion" ];
var cWords = (num >= 1 && num < 2) ? "Dollar and " : "Dollars and ";
var nLeft = Math.floor(num);
for (var i = 0; nLeft > 0; i++) {
if (nLeft % 1000 > 0) {
if (i != 0)
cWords = ConvertToHundreds(nLeft) + " " + aUnits[i - 1] + " " + cWords;
else
cWords = ConvertToHundreds(nLeft) + " " + cWords;
nLeft = Math.floor(nLeft / 1000);
num = Math.round(num * 100) % 100;
if (num > 0)
cWords += ConvertToHundreds(num) + " Cents";
else
cWords += "Zero Cents";
return cWords;
You can use the following script for the custom calculation for the words field when the number field is named "Number":
event.value = "";
var f = this.getField("Number");
if(f.valueAsString != "") {
event.value = ConvertToWords(f.value); -
How to convert ascii value into character and vice versa
Hello the java world people,
I want to convert each characters from my array into their corespondent ascii value and vice versa, how can I do that ?The term "ASCII" is often used very loosely.
Java char values are UNICODE and the ASCII codes are indentical to UNICODE characters in the range 0 .. 127. UNICODE values 128 and above don't have coresponding ASCII values, though 128-255 corespond to ISO-8859-1 which is one of the encodings often called "extended ASCII".
As shown above you can covert between chars and coresponding int value simply with a cast, but you should be aware that the more exotic characters will not give you sensible values. -
Converting currency fields into strings without separators
Hi all,
Currently i'm using the write statement to do the conversions.
data : amt(30).
write bseg-dmbtr into amt currency 'USD'.
However the output is in "123,456.00" format.
I need the output in "123456.00" without the commas.
Other than doing a "REPLACE" command for the commas in the amt string, is there a better way of getting the desired currency output without commas?
regardsAhhhh thanks!
I get error while rewarding the solution? I'll try again later
Message was edited by: Bee Huat, Leonard Yong -
Convert Exponential value into float value
Exponential format example 005.0000E-02 Result 0.05
public static double convertExp(String slice)
int i=0,j=0;
int symbolpos=0;
int sign=0;
int power=0;
StringBuffer PowValue=new StringBuffer();
StringBuffer ExpValue=new StringBuffer();
while(i<slice.length())
if(slice.charAt(i)=='-') {sign=-1;}
if(slice.charAt(i)=='+' || slice.charAt(i)=='-') {
symbolpos=i+1;
PowValue.append(slice.charAt(symbolpos));
PowValue.append(slice.charAt(symbolpos+1));
if(slice.charAt(i)!=('e') || slice.charAt(i)!=('E'))
if(j<=(slice.length()-5))
ExpValue.append(slice.charAt(j));
j++;
i++;
int powInt=Integer.parseInt(PowValue.toString());
Double expFot=Double.parseDouble(ExpValue.toString());
if(sign==0)
return (expFot * Math.pow(10,powInt));
else if(sign==-1)
return (expFot/(Math.pow(10,powInt)));
else
return 1;
Function return double value
double tummy=convertExp(imageviewerdisplay.Slicethick);
float convertslicevalue=(float)tummy; //double to float......Best 3rd post ever?:-) Except that this was the 1st post .. #2 & #3 are in the resurrected zombie.
{color:0000ff}http://forum.java.sun.com/thread.jspa?threadID=583688{color}
And, um, I've heard of a double chin, but what's this?double tummy=convertExp(imageviewerdisplay.Slicethick);db -
In BO 4.0,how to convert field values into column heading.
Currently Product Codes are represented in "Code" and "Value" fields.
Please retain the code and value fields, so that if the user adds another code and immediately needs to report on them they can through this functionality.
Current:
Fund Code
Code
Value
ABC1
Embassy Series
XYZ123
ABC1
FMI
19837
ABC1
Gladis Short Name
FUJHAT
Required:
Fund Code
Embassy Series
FMI
Gladis Short Name
ABC1
XYZ123
19837
FUJHATHi Archana,
I think you need to use a Cross Tab on your report but also you will need to apply Sections on the Fund Code dimension.
ie
Section 1 - ABC1
Crosstab
Section 2 - ABC2
Crosstab
Section 3 - ABC3
Crosstab
With regards
Gill -
I'm using enums that have assigned values, like so:enum Alphabet {
a(101), b(135), c(22), d(5);
private final int value;
Alphabet(int i) { value = i; }
}OK, so I can get a value from an Alphabet object by Alphabet item;
item = Alphabet.c;
int i = c.value;Cool. But how do I go the other way, where I have an int value and I need to get the corresponding Alphabet object? Is that what EnumMap is for? If so it seems kind of inefficient, since my values can be all over the map, so to speak.What's wrong with this?
enum Alphabet {
a(101), b(135), c(22), d(5);}
I can't get that to compile. You have to provide a constructor in the enum to tell it what the values in the ()s means.
Is there some reason the alphabet isn't a character
array instead?My example of Alphabet was just generic. My real application is using enum to describe possible values within a protocol structure. -
Converting a value into decimals in smart form.
i have a variable(amt) in a smartform in which i have a value '600000.00' . When i display it, i do like this..
&amt(1.0)& // cuz i want 60,000
but it displays '6' ..
why ? plz help... Thanks !!&amt(n)& will tell the number of digits is n.
&amt(.n)& will tell us the number of digits after decimal point.
We can combine both these two like
&amt(n.n)& . So problem solved.
Maybe you are looking for
-
Hi, When I insert a lightscribe DVD/CD into a lightscribe optical drive, then when I click to open the DVD, I faced this error 'How do you want to use this disc', although the DVD was full of data. When opening these lightscribe DVD/CD via NON ligh
-
Dear all, I need a transaction or report in FS-CD so that I can see the insurance objects and contract accounts are blocked for dunning. Can you please help me on this Thanks, Latifaa
-
Communication errors when iPod 2nd gen connected to car stereo
So a while back I ultimately decided to update my 2nd gen iPod touch from iOS 3.1.3 to the highest it'll support, which I believe is iOS 4.2.1. The update went fine, and everything seemed to be working alright until I plugged it into my car's stereo
-
How to get the Text name to pass in the parameter header in save_text
Hi, I am trying to change the long text of operation for historical order by using the flat file.I am using the save_text to do this.I would like to know how to get the text name in order to pass the parameter header in save_text. I went to the
-
ITunes will not open because the iTunes folder can't be found!
Okay, so I am trying to open iTunes and it is saying it can't open because the iTunes folder can't be found or created. The problem is it is RIGHT WHERE it is supposed to be, in the music folder. I click in and try, but it doesn't work. AT ALL. I'm m