Hey Greg, thanks for the new code to try out and look at. I will look this over some more. Thanks for the links.
j. Sent with [Proton Mail](https://proton.me/mail/home) secure email. On Sunday, April 27th, 2025 at 4:30 PM, Greg Dove <greg.d...@gmail.com> wrote: > Hi Jim, > > As near as I can tell, you're not using the amf extension on the php side for > what it is really intended for - and you're just calling a regular php script > file. > > Also, you're using HTTPService, which is not related to amf support which is > more what the ResultEvent relates to in this case. > > You can see what events HTTPService dispatches from the documentation in the > source code: > https://github.com/apache/royale-asjs/blob/develop/frameworks/projects/Network/src/main/royale/org/apache/royale/net/HTTPService.as > > And I think there are a few examples in the 'examples', here's one here: > https://github.com/apache/royale-asjs/blob/a49175300d6ceafa833cc8cc304223773297bac4/examples/royale/MobileTrader/src/main/royale/models/ProductsModel.as#L122 > > If you want to use actual amf services, that requires more setup on the php > side. There are some examples using amf in the royale codebase, but using > blazeds, not with php, however in theory it should not be different on the > royale side. > > On Mon, Apr 28, 2025 at 8:15 AM Jim McNamara <jmcnamara10...@proton.me> wrote: > >> Hi all- >> >> This code doesn't seem to want to fire onResult function after adding >> the event listener service.addEventListener(ResultEvent.RESULT, onResult); >> >> It is kind of a show stopper. >> >> If i call a mock test in the code below from the constructor it worked, but >> if it is executing where all the service stuff is ... >> in fetchdata it is not picking up the listener and running with it going to >> the onResult function. >> >> The test value "go3" only gets called when running a test in the constructor >> and not when i add the eventlistener and run the service. >> >> I saw an issue with amfphp with royale and an open issue don't know if the 2 >> are related #119 >> >> It is really kind of technical for me to know for sure. >> >> thanks, >> j. >> >> package testpkg { >> import org.apache.royale.core.UIBase; >> import org.apache.royale.html.elements.Button; >> import org.apache.royale.events.MouseEvent; >> import org.apache.royale.net.HTTPService; >> >> import org.apache.royale.net.events.ResultEvent; >> import org.apache.royale.net.events.FaultEvent; // Import FaultEvent for >> error handling >> import org.apache.royale.jewel.List; >> import org.apache.royale.collections.ArrayList; >> import org.apache.royale.jewel.Alert; // Import Alert for showing messages >> import org.apache.royale.events.Event; >> import org.apache.royale.jewel.Grid; >> import org.apache.royale.jewel.GridCell; >> import org.apache.royale.html.elements.H3; >> import org.apache.royale.html.beads.layouts.Paddings; >> import org.apache.royale.jewel.Card; >> import org.apache.royale.jewel.supportClasses.card.CardHeader; >> import org.apache.royale.jewel.supportClasses.card.CardPrimaryContent; >> >> public class SqliteQuery extends UIBase { >> public var _listData:ArrayList= new ArrayList(["Blueberries", "Bananas", >> "Lemons", "Oranges", "This is a long item render to try long texts" >> ]);; >> private var list:List = new List(); >> >> [Bindable] >> public function get listData():ArrayList { >> return _listData; >> } >> >> public function set listData(value:ArrayList):void { >> _listData = value; >> } >> >> public function SqliteQuery() { >> // Initialize listData as ArrayList >> super(); >> testOnResult(); >> var grid:Grid = new Grid(); >> grid.gap = true; >> grid.itemsVerticalAlign = "itemsSameHeight"; >> >> var paddings:Paddings = new Paddings(); >> paddings.paddingTop = 0; >> paddings.paddingLeft = 50; >> paddings.paddingRight = 50; >> paddings.paddingBottom = 50; >> grid.addBead(paddings); >> >> var card:Card = new Card(); >> var cardHeader:CardHeader = new CardHeader(); >> var headerText:H3 = new H3(); >> headerText.text = "Default"; >> headerText.className = "primary-normal"; >> cardHeader.addElement(headerText); >> card.addElement(cardHeader); >> >> var list:List = new List(); >> list.id = "list1"; // Use `id` instead of `localId` >> list.width = 200; >> list.height = 300; >> list.selectedIndex = 2; >> list.dataProvider = listData; >> list.addEventListener("change", onChange); >> list.addEventListener("error",onError); >> //listData = new ArrayList(); >> >> // Apply a border style to the List >> list.className = "listBorderStyle"; // Link the CSS class to the List >> // Add the scrolling beads for horizontal and vertical scrolling >> //list.addBead(new HorizontalListScroll()); // For horizontal scrolling >> // list.addBead(new VerticalListScroll()); // For vertical scrolling >> >> var cardPrimaryContent:CardPrimaryContent = new CardPrimaryContent(); >> cardPrimaryContent.addElement(list); >> card.addElement(cardPrimaryContent); >> >> var gridCell:GridCell = new GridCell(); >> gridCell.desktopNumerator = 1; >> gridCell.desktopDenominator = 2; >> gridCell.tabletNumerator = 1; >> gridCell.tabletDenominator = 2; >> gridCell.phoneNumerator = 1; >> gridCell.phoneDenominator = 1; >> gridCell.addElement(card); >> grid.addElement(gridCell); >> >> addElement(grid); >> } >> >> public function getld():ArrayList { >> return listData; >> } >> >> // Fetch data and populate listData >> public function fetchData():void { >> Alert.show("go2"); >> var service:HTTPService = new HTTPService(); >> //service.method="POST"; >> //service.url = "http://127.0.0.1:8000/test.php"; >> service.contentType = "application/json"; // For JSON requests >> service.url = "http://127.0.0.1:8000/test.php?param1=foo¶m2=bar"; >> service.method = "GET"; // Use GET for query parameters >> >> Alert.show("Before adding listener"); >> service.addEventListener(ResultEvent.RESULT, onResult); >> Alert.show("Listener added"); >> >> service.send(); >> Alert.show("Service sent"); // Check if this line is being executed >> } >> >> private function onResult(event:ResultEvent):void { >> Alert.show("go3"); >> Alert.show("Result received: " + event.data.toString()); // Inspect the >> result >> // The response data is a JSON object with foo and bar properties >> var responseData:Object = event.data; >> >> // Array to hold the new items to add to the List >> var items:Array = ["foo"]; >> Alert.show("test1"); >> // Loop through the response data (assuming it's an array of objects) >> for (var i:int = 0; i < responseData.length; i++) { >> var item:Object = responseData[i]; >> >> // Create a new object with the foo and bar properties >> items.push({foo: item.foo, bar: item.bar}); >> } >> Alert.show("test2"); >> >> // Now set the items array to the List's dataProvider >> // Use list.dataProvider directly, and make sure to use an ArrayList >> list.dataProvider = new ArrayList(items); >> >> // Optional: Log the data to verify >> Alert.show( list.dataProvider.source); >> } >> >> private function onChange(event:Event):void { >> Alert.show("Selected: " + event.target.selectedItem); >> } >> >> private function onError(event:ErrorEvent):void { >> Alert.show("Error occurred: " + event.toString()); >> } >> >> private function testOnResult():void { >> var resultEvent:ResultEvent = new ResultEvent(ResultEvent.RESULT, false, >> false, "Mock Result"); >> onResult(resultEvent); // Directly trigger onResult with mock data >> } >> >> } >> } >> >> Sent with Proton Mail secure email.