Search Flex Components Free

Custom Search
Showing posts with label Flex Vs Dot Net (c#). Show all posts
Showing posts with label Flex Vs Dot Net (c#). Show all posts

December 17, 2007

Pointing Hibernate to MySql

Continuing on from my last post, we'll now try getting the crm sampel working with MySQL and Hibernate. Again, I'm going to try and keep this simple. Here's the steps.




1. Recreate the db in mysql. If you look in samples\web-inf\db\crm you will find a file called crm.script which has the sql statements you will need.

2. Make sure you have the mysql-jdbc-connector libraries. Put the .jar file in the samples\web-inf\lib folder.

3. Edit the HsqlServlet.java file in samples\web-inf\src\samples\crm as follows:

change the connection.driver_class to com.mysql.jdbc.Driver
change the connection.url to jdbc:mysql://127.0.0.1:3306/crm (assuming defaults)
change the connection.username and connection.password
change the dialect to org.hibernate.dialect.MySQLDialect
comment out the hbm2ddl.auto line
4. Compile the HsqlServlet.java file into samples\web-inf\classes.

5. Run FDS. Keep an eye out on the console for any errors.

6. Open the companyapp.mxml in a browser.

ResourceBundle files in localized Flex apps

Problem: You are creating a flex app in flexbuilder that will be available in two languages, English and French.

You create the following:
\locale\en_US\Flexapp.properties
\locale\fr_FR\Flexapp.properties

You throw a string in each:
after=after
after=après

You compile the application and it defaults to english and comes up fine
You change the compiler arguments in project properties to -locale fr_FR and run it and instead of an è you get either a blank or a square

Solution: The text encoding type of the Flexapp.properties file in flexbuilder defaults to ISO-8859-I. Cut out all the text in the file, save it. Go to the properites of the file and change the encoding to UTF-8. Then paste your text back in and save. Now when you compile and run the letters should come up fine.

asp.net c# webservice consumed by flex

Someone on the flexcoders asked to be provided with a simple example of flex consuming an asp.net webservice. I know this might be VERY simple, but it proves functionality.

ASP.NET Webservice in C#

using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Diagnostics;using System.Web;using System.Web.Services;namespace Director{ public class Hello : System.Web.Services.WebService { public Hello() { InitializeComponent(); } #region Component Designer generated code private IContainer components = null; private void InitializeComponent() { } protected override void Dispose( bool disposing ) { if(disposing && components != null) { components.Dispose(); } base.Dispose(disposing); } #endregion [WebMethod] public string HelloWorld(string variable) { return "Hello " + variable; } }}
Flex Application:

If you're accessing a webservice on another machine or domain, don't forget the crossdomain.xml file in the IIS root:

asp.net C# data webservice for Flex

This is kinda the next evolutionary step from my previous blog. In this example I demonstrate how to get an array of records from .net to flex. Again, I have simplified this for the purpose of this blog. In the asp.net webservice, I would normally retrieve records from the database and then iterate thru the dataset to build my array, while here in this example I have just populated the array manually.

C# Webservice:


using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Diagnostics;using System.Web;using System.Web.Services;using System.Xml.Serialization;namespace Director{ public class MemberService : System.Web.Services.WebService { public MemberService() { InitializeComponent(); } private IContainer components = null; private void InitializeComponent() {} protected override void Dispose( bool disposing ) { if(disposing && components != null) { components.Dispose();} base.Dispose(disposing); } [WebMethod] [XmlInclude(typeof(Member))] public Member[] getMembers() { ArrayList al = new ArrayList(); Member mem = new Member(0,"bob","bsmith","password1", "bob@abc.com","Initiate",false,DateTime.Now); al.Add(mem); Member mem1 = new Member(0,"jim","jsmith","password2", "jim@abc.com","Member",false,DateTime.Now); al.Add(mem1); Member mem2 = new Member(0,"ed","esmith","password3", "ed@abc.com","Officer",false,DateTime.Now); al.Add(mem2); Member mem3 = new Member(0,"neil","nsmith","password4", "neil@abc.com","Guest",false,DateTime.Now); al.Add(mem3); Member[] outArray = (Member[])al.ToArray(typeof(Member)); return outArray; } } [Serializable] public class Member { public int memberid; public String name; public string username; public string password; public string email; public string comments; public bool disabled; public DateTime created; public Member(int _memberid, string _name, string _username, string _password, string _email, string _comments, bool _disabled, DateTime _created) { memberid = _memberid; name = _name; username = _username; password = _password; email = _email; comments = _comments; disabled = _disabled; created = _created; } public Member(){} }}
In Flex, the Member.as file:
package com.abc.ws{ [Managed] [RemoteClass(alias="com.abc.ws.Member")] public class Member { public var memberid:int; public var name:String; public var username:String; public var email:String; public var password:String; public var comments:String; public var disabled:Boolean; public var created:Date; public function Member(obj:Object = null) { if (obj != null) { this.memberid = obj.memberid; this.name = obj.name; this.comments = obj.comments; this.username = obj.username; this.email = obj.email; this.disabled = obj.disabled; this.created = obj.created; this.password = obj.password; } } }}In Flex, the application:

Related Flex Tutorials