Solved

How do I send values in datagrid to server using actionscript

Posted on 2009-05-07
4
591 Views
Last Modified: 2012-05-06
I'm relatively new to Flex.  I have a small sample application running that is receiving/sending data from a server and populating components.

 I'm having problems sending the values from a datagrid (could be a list) to the server.  I tried a form, but I can't seem to get the form to post to the server.  The error handler executes before reaching the server.  I don't have to use a form, but I thought it was going to be the easiest method.  
.........
 
This is the function I have setup to send the data.  I'm trying to send the values in the data grid, "selectedvalues" to the server.
 
I suspect I'm missing a simple concept... I hope.
 
Thanks!
 
private function saveRequest():void
				{
					saveHttp = new HTTPService();
					CursorManager.setBusyCursor();
varHttp.url = "http://bl-ux-ssd1.na.dir.bunge.com:9080/SASStoredProcess/do?_program=SBIP%3A%2F%2FFoundation%2FBIP+Tree%2FUsers%2Fcjobell%2Flimit_test2%28StoredProcess%29&_action=strip&_debug=&_selection=" ;
					saveHttp.method = "GET";  
					saveHttp.addEventListener("result", saveRuleHandler);
                	saveHttp.addEventListener("fault", limFaultHandler);
					saveHttp.send(parameters);
					
					
				}			
				
				
			private function limFaultHandler(event:FaultEvent):void{
				CursorManager.removeBusyCursor();	
				Alert.show("There was a problem","Error");
			}
			
			private function limResultHandler(event:ResultEvent, token:AsyncToken):void{
				limitvars = event.result.row;	
				CursorManager.removeBusyCursor();		
			}
			private function varResultHandler(event:ResultEvent, token:AsyncToken):void{
				resvars = event.result.row;	
				CursorManager.removeBusyCursor();		
			}
			
			private function saveRuleHandler(event:ResultEvent):void{
							CursorManager.removeBusyCursor();		
			}
			
		]]>
		
		
	</mx:Script>
	 
	 <mx:ArrayCollection id="limitvars2" source="{ArrayUtil.toArray(limitvars)}"/>
	
	 
 
	<mx:ViewStack x="41.5" y="47" id="viewstack1" width="692" height="402" cornerRadius="20">
		<mx:Panel label="Title" width="100%" height="100%" backgroundColor="#FBF6F6" cornerRadius="20" backgroundAlpha="0.49">
			<mx:Text text="Limit Manager" width="205" x="10" y="45" fontSize="16"/>
			<mx:HBox width="662" height="142" backgroundColor="#FCF9F9" cornerRadius="20" backgroundAlpha="0.02" horizontalAlign="center" verticalAlign="bottom">
				<mx:TextArea width="600" height="97" wordWrap="true" editable="false" enabled="true" alpha="0.0" backgroundAlpha="0.0">
					<mx:text><![CDATA[The limit manager allows you to create groups of limit rules.  Each limit rule is comprised of a set of instructions for reporting limit violations.  This wizard will take you through the steps of createing a limit rule set(s).
						 ]]>
</mx:text>
				</mx:TextArea>
			</mx:HBox>
		</mx:Panel>
		<mx:Panel label="Step 2"  width="100%" height="100%" layout="absolute"  title="Limit Rule Wizard" fontSize="12">
			<mx:ComboBox 	x="204" y="38" id="limvars" dataProvider="{limitvars}"
							prompt="Please select a variable"
							width="295"
							editable="false"
							close="getlimvarvalues(event);">
			</mx:ComboBox>
			<mx:DataGrid x="191" y="96" height="193" dataProvider="{resvars}"  dragEnabled="true" dragMoveEnabled="true" width="137">
				<mx:columns>
					<mx:DataGridColumn dataField="data" headerText="Unique values" />
				</mx:columns>
			</mx:DataGrid>
				
			
			<mx:Text x="10" y="99" text="Part B. Drag the desired values to the selected list" width="173" height="65"/>
			<mx:Text x="10" y="10" text="Part A. Select a variable for the limit rule set"/>
			
			<mx:Form x="368" y="79" width="282" height="262">
				<mx:DataGrid height="193" id="selectedvalues" dropEnabled="true" dataProvider="[]" width="137">
					<mx:columns>
						<mx:DataGridColumn  headerText="Selected values" dataField="data"/>
					</mx:columns>
					
				</mx:DataGrid>
				<mx:FormItem label="Save the limit rule set">
					<mx:Button label="Save it!" click="saveRequest();"/>
				</mx:FormItem>
			</mx:Form>
		</mx:Panel>
		<mx:Panel label="Step 2" width="100%" height="100%" >
		</mx:Panel>

Open in new window

0
Comment
Question by:thebellman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:Fuzzy_Logic_
ID: 24330218
You probably know this but just in case

From AdobeLiveDocs:

send      ()      method       
public function send(parameters:Object = null):AsyncToken

Executes an HTTPService request. The parameters are optional, but if specified should be an Object      containing name-value pairs or an XML object depending on the contentType.

Parameters
      parameters:Object (default = null)  An Object containing name-value pairs or an XML object, depending on the content type for service requests.

Returns
      AsyncToken  An object representing the asynchronous completion token. It is the same object available in the result or fault event's token property.



Charles is also a useful tool, especially in this case: http://www.charlesproxy.com/ ( bizarrely I've just recommended this tool to someone else )

Regards

FL
0
 

Author Comment

by:thebellman
ID: 24330693
Thank you for the response - the link to Charles was worth everything! - Great application!!!!

I'm going to show my lack of knowledge on flex...

I thought that was the right way to accomplish it.  However, I still couldn't get it to pass the parms.  This is what I originally had in my request.   Do I need to step through the grid to build an array?


I would except that the data from the grid be passed on the url as a parameter.  
private function saveRequest():void
				{
					var parms:Object = new Object();
					parms.tags=selectedvalues.data;
					
					saveHttp = new HTTPService();
					CursorManager.setBusyCursor();
saveHttp.url = "http://bl-x-ssd1.na.dir.bunge.com:9080SASStoredProcess/" ;
					var responder:ItemResponder = new ItemResponder(saveRuleHandler, limFaultHandler);
					var token:AsyncToken = saveHttp.send(parms);
					token.addResponder(responder);
					saveHttp.resultFormat="e4x"		
				}			

Open in new window

0
 
LVL 5

Accepted Solution

by:
Fuzzy_Logic_ earned 250 total points
ID: 24331054
You can send an array of strings, you will receive a string at the other end.
0
 

Author Comment

by:thebellman
ID: 24334866
Thanks - For any one with a similar issue -

I added this one line:

var dgList:ArrayCollection = this.selectedvalues.dataProvider as ArrayCollection;

and sent the parameters:
var token:AsyncToken = saveHttp.send(dgList);

it works.!
                              
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
We have put together a white paper that aims to explain how MSPs can both improve their offering and ease the pain of after-hours service by: -Suggesting changes to workflow -Indicating how to rework policy to suit your team -Providing ConnectW…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question