[Remoteclass (alias = "flex. samples. Product. Product")], front-end and back-end data update example

Source: Internet
Author: User

[Problem description] Click the table on the left. The data information is displayed on the right. Now, the data on the right is changed, and the table on the left is changed. This is the front-end data update, when the page is refreshed, the data is returned to before the update.

If you click the update button, data is updated in the background. This means that if you refresh the page, the changes will still take effect.

[Code analysis] the front-end master file mxml contains such code <Productform Product = "{product (list. selecteditem)}"/>Instantiate a product with the selected data list. selecteditem and assign this object to the productform of the product. (Here, product () calls the instantiation function in the foreground product. As. This file contains such a statement. [Remoteclass (alias = "flex. samples. Product. Product")]The role is to set the front-end product. as and background product. java is mapped together, so that the product retrieved from the getproduct () method in the background is returned to the foreground with the product. the as class is represented, and the product class sent from the foreground to the background is treated as a product. java class) and in productform <Mx: Form width = "100%"> </P> <p> <mx: formitem label = "name"> <br/> <mx: textinput id = "productname" text = "{product. name} "/> <br/> </MX: formitem> </P> <p> <mx: formitem label =" category "> <br/> <mx: textinput id = "category" text = "{product. CATEGORY} "/> <br/> </MX: formitem> </P> <p> <mx: formitem label =" image "> <br/> <mx: textinput id = "image" text = "{product. image} "/> <br/> </MX: formitem> </P> <p> <mx: formitem label =" price "> <br/> <mx: textinput id = "price" text = "{product. price} "/> <br/> </MX: formitem> </P> <p> <mx: formitem label = "Description" width = "100%"> <br/> <mx: textarea id = "Description" text = "{product. description} "width =" 100% "Height =" 100 "/> <br/> </MX: formitem> </P> <p> </MX: Form>This code displays the values of product in the textinput control, followed by the code in productform. <Product ID = "product" <br/> name = "{productname. text} "<br/> Category =" {category. text} "<br/> price =" {number (price. text)} "<br/> image =" {image. text} "<br/> description =" {description. text} "/>The update is performed on the front-end, which is the same as the update in the textinput control. Background updates must be triggered when the update button is clicked. <Mx: controlbar> <br/> <mx: button label = "Update" Click = "srv. update (product); "/> <br/> </MX: controlbar>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.