Visure Easy - Direttamente sul tuo smartphone

Online il nuovo sito per il reperimento semplice e veloce delle visure direttamente sul tuo cellulare!

Attraverso il browser del tuo smartphone potrai richiedere, pagare e scaricare la tua Visura!!

Visure Easy Mobile

Xcode 4 Tip: Automatically make IBOutlet, property, dealloc and

Xcode 4 Tip:  Automatically make IBOutlet, property, dealloc and synthesize!


Are you bored to write always the same line of code in order to make an IBOutlet, property, synthesize, dealloc and then connect it to the gui in the interface builder?


1) Open Xcode 4
2) Open the xib file
3) Split the view so you can see the gui and the header file by clicking in the top on the right the center icon in the editor section.
4) Go to gui element (uibutton, uitextfield etc.) 
5) Menu -> View -> Utilities -> Connection Inspector
6) Select on the Connection Inspector "New referencing outlet"
7) Drag it in your header .h file

In order to make as property drag out outside the interface before the @end!!

Thanks to this answer I find this very very good tip:

Xcode 4 Tip: Automatically make IBOutlet, property, dealloc and

Xcode 4 Tip:  Automatically make IBOutlet, property, dealloc and synthesize!


Are you bored to write always the same line of code in order to make an IBOutlet, property, synthesize, dealloc and then connect it to the gui in the interface builder?


1) Open Xcode 4
2) Open the xib file
3) Split the view so you can see the gui and the header file by clicking in the top on the right the center icon in the editor section.
4) Go to gui element (uibutton, uitextfield etc.) 
5) Menu -> View -> Utilities -> Connection Inspector
6) Select on the Connection Inspector "New referencing outlet"
7) Drag it in your header .h file

In order to make as property drag out outside the interface before the @end!!

Thanks to this answer I find this very very good tip:

Mac Os eject cd dvd problem

Mac Os Eject cd/dvd Problem


Your cd/dvd drive can't eject the cd, by keyboard input?
The finder can't show your cd/dvd drive?


1) Open Terminal
2) Type drutil tray eject

From Java To Objective-C: String

From Java To Objective C: Strings

My Notes (part 2)

This is a very short introduction from my notes.

A good and complete starting point can be found by google.

The String.

In java we have String Class that represent a string, in objective C there is a NSString object.

Each string constant double quote in objective-c must be prefixed by @

Also in objective C, NSString is immutable like java String.

.objective c version

  • NSString aString = @"hello world";

  • NSString aString2 = [[NSString alloc] initWithString:@"Hello World2"]; 
  • [aString release]; 

  • #define CONSTANT1 @"HELLO";

  • NSLog(@"debug string");

  • NSString *ageString = [NSString stringWithFormat:@"%@ concatenate with %@", "age:", 18];

.java version

  • String aString = "hello world";

  • String aString2 = new String("Hello World 2");

  • public static final String CONSTANT1 = "HELLO";

  • System.out.println("debug string");

  • String ageString = "age:" + " concatenate with " + 18;

From Java To Objective-C

From Java To Objective C 

My Notes (part 1)

This is a very short introduction from my notes.

A good and complete starting point can be found by google.

I'm a java developer and when I'm going to learn objective-c for the iphone development the matching between the 2 languages became automatic.

Objective C is standard ansi C with object oriented extension.

So many OO arguments found in java can be find in objective C.

In objective C the class usually is split in two file:

  • .h file for the class definition.
  • .m file for the class implementation.

Let's go to see some code, this is only my simple notes.

.h file example

#import <UI/Class.h> //like import in java

//interface is a compiler directive, it tell that there is a class definiton

//myClassName the className

//NSObject the parent object

//<aProtocol> it respect the protocol definition (like abstract class in java)

@interface MyClassName: NSObject <aProtocol>


    int count; //a simple primitive type

    id *data; //Weak Type

    NSString *aString; 

//String type. *stay for pointer. all the instance object variable

//use this pointer notation


//property declare a class property

//nonatomic or atomic value regard the thread safety in the accessor method

//retain in the set accessor the variable value is retained

@property (nonatomic, retain) NSString aString

//this is a method interface definition


@end //end interface declaration

.m file example

#import "MyClassName.h"  //import the class interface definition file

@implementation MyClassName

@synthesize aString; 
//It tells to compiler to make automatically get/set method 
//for property aString

    //insert here the method logic


.java Equivalent

import ui.Class;

class MyClassName extends NSObject implements aProtocol
    private int count;
    private Object data;
    private String aString;

    public void setAVar(String s) { this.aString = s;}
    public String getAString (return this.aString;)

    Object aMethod (String paramName) { //logic }

Flex AS3 Webservice Proxy and Object Binding

Flex AS3 Webservice Proxy and Object Binding


In the previous article we see how a flex as3 can call webservice simply by using the Webservice class.
Let's see about webservice resultformat and data binding.

The Webservice Client Result Format in AS3

The webservice client result format can be "Object, xml, or e4x".

  • The Object(default resultFormat) return data in form of ObjectProxy. ObjectProxy contains different datatypes like ArrayCollection etc. You would have to handle and parse this result obtaining the data you expect.
  • XML format returns the data as an array of XMLNodes.
  • E4X format gives an XMLList. 

But like jax-ws java client maked with netbeans wizard I wish to search about automatic data binding.

It shows how make the proxy objects by using the wsdl.
This is done by flex builder ide.

Import Webservice into flex builder

The following link show the detailed steps

I write only some notes about this.
First of all, Import webservice inside flex builder project:

Data Menu -> Import Webservice and so on.

Then in order to call the webservice use the

NameService class.
Where Name is the name of webservice.

var ws:NameService = new NameService();

The autogenerate procedure make also one listener for each operation inside the webservice.
So add the listener and make the proper function called by the listener


the onResultOperation1 definition is like this:

private function onResultOperation1(res:Operation1ResultEvent):void
   var value:Operation1ReturnType = res.result._return;

The Operation1ResultEvent and Operation1ReturnType is created by flexbuilder during the webservice import.
Note that Operation1ReturnType is the real return type used also in the webservice (server side).
So in this function you obtain directly the returnType Object.

Ok, for calling the webservice, first assign the request variable.

//inside costructor possible parameter to be pass to the webservice //operation
var param:Operation1_request = new Operation1_request(); 
ws.Operation1_request_var = param;

call it



In this way more coding works is done automatic by the ide.

Java Hello World

Java Hello World


The simplest programming language example!

//define a class HelloWorld
public class HelloWorld 
    //define a public static method in the class that make an entry point for the application.
    //It takes an array of String parameter
    public static void main(String[] args) 
        //Use the base System api to print a "Hello World" string in the standard output.
        System.out.println("Hello World"); 


In a simple Java Hello World example come into play various topics:

  • the class notion
  • the public modifiers
  • the static method modifiers
  • Array type
  • String type
  • a static method call (System.out.println(String a))

So, You have to start with an object oriented programming tutorial within java tutorial in order to start programming in java.

Maintaining state in Java Webservice(JAX-WS)

Maintaining state in Java Webservice(JAX-WS)


This little article start point is the need of get the current session from a flash swf.
I try to explain: The web application has a login form and after the user is authenticated a session is created and mantained, so the need is to access to this value into the session from flash that calls a webservice in the same service.


Server side: JSP, Servlet etc. for user login.
Server side: Webservice for reporting stuff.

Client side: html form for login
Client side: flash swf (created with flex) for reporting gui. it access the webservice to obtaining reporting data and draw it. when the webservice is called the session data created in login step is required.

The Webservice

The webservice is created like in the previouse article.
But in order to get the current session a MessageContext is required.
So declare it by the @Resouce annotation, and get the HttpSession from it!

public class testWS {

    private WebServiceContext context;
     * Web service operation
    @WebMethod(operationName = "sayHello")
    public String sayHello(@WebParam(name = "name")
    String name)
        String ret = "";
        MessageContext mc = context.getMessageContext();
        HttpSession session = ((HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST)).getSession(false);
        if (session == null)
        {ret =  "hello: NO SESSION";}
            Enumeration en = session.getAttributeNames();
            while (en.hasMoreElements())
                String key = (String) en.nextElement();
                ret += key + " " + session.getAttribute(key) + "\r\n";
        return ret;



That's all.
The client side you can see in the previous article


For a complete discussion about session mantaining

Flex AS3 call a Java Webservice

Flex AS3 call a Java Webservice


Webservice is a standard in soa architecture.
Flex is a leading tecnology for client side so let's see how actionscript 3(the flex programming language) can call a java(jax-ws) webservice.

Starting Point

The main step are:

  1. Make a WebProject with a Webservice
  2. Make a MXML in flex side and code the call

The webservice:

Two click with netbeans header and you can obtain this code:

package webservice;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

public class testWS 
    @WebMethod(operationName = "sayHello")
    public String sayHello(@WebParam(name = "name")
    String name)
        return "hello " + name;


The Action Script Side inside mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="absolute" click="useWebService()">

import mx.rpc.soap.WebService;
public function useWebService():void
var ws:WebService = new WebService();
private function onResult(event:ResultEvent):void
 trace("result " + event.result);
private function onFault(fault:FaultEvent):void
 trace("fault " + fault);

To see the result debug the flex application and see at console only after deploy the webservice.


This is the runtime version.

Java and BlazeDS by Example

The interaction between Java and Flash
(part 3 - BlazeDS)

BlazeDS - Introduction

Let's see how to make a simple example in order to get in communication a java server side(with blazeDS) and action script 3 client side inside Flash CS3 (No Flex!!)

Server Side:

Download the BlazeDS binary distribuition

The BlazeDS binary distribuition is a war, so it is a web application.
Decompress it in a directory.
Make a new java webproject and update the web-inf directory in the empty project with the files contained in decompressed war into web-inf.

Try to deploy it into the server and be sure that it is deployed correctly.

I'm take the example step by reading - RPC service example

Now in the project make the class EchoService like the example in the link:

package remoting; 

public class EchoService 
    public String echo(String text) 
    { return "Server says: I received '" + text + "' from you"; } 

If you build the project, then you see that inside WEB-INF/classes/remoting there is the EchoService.class file!

Now you have to define a destination and reference one or more channels for data transport.
So make EchoService.class the remoting destination by editing WEB-INF/flex/remoting-config.xml and adding the following code:

<destination id="echoServiceDestination" channels="my-amf">

With the latest xml you reference my-amf channel, but it isn't setup yet.
So add the following code to WEB-INF/flex/services-config.xml

<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel"> 
<endpoint url="http://{}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/> 

This code specifes also that client uses a non-pooling AMFChannel.
Note that you must replace, server.port, context.root with the correct values

Client Side:

Make An ActionScript file and inside the actions put this source code:


//replace with you server ip or servername
var url:String = "";
var nc:NetConnection;
var responder:Responder;                   
nc = new NetConnection();
nc.connect(url);"echoServiceDestination.echo", new Responder( onResult, onError ), "TEST!");

function onResult( text:String ):void 
     trace("Result: " + text);
function onError( error:* ):void 
        trace("CALL ERROR:");               
        for(var i:String in error)
        trace(i + " :: " + error[i]);


BlazeDS seems to be a powerful solution, this example show only a simple RPC example.

Make GUI with Flash and code by Flex!

Flex and Flash CS3: How they works together


In some previous article, I'd searched for a java ee to flash communications framework.
Webservice as3 library disappears in the third version of action script after as2.
Xml parsing and unmarshalling is too coding expensive.
AMF works but by java side I can only with OpenAMF that supports the old AMF0 version.

When I'm search for this solution I'm reading about different technologies and library and It seems that adobe flex is more powerful when you must code more by client side.

As a matter of fact Flex supports Webservice, BlazeDS tutorials talks about Flex, and many forums post talks about the flexibilty of flex.

So I think that Adobe wants to move the coding capabilities of SWF from Flash CS Actionscript to other frameworks that works too with ActionScripts but is equipped with a powerful compiler tool and library. So the developers team and Webdesigner team can works respectively with differents development software.

I'm starting to study how the web designer can go on in working with his flexible tool: flash cs3 and the developers team can integrate the graphic designer's project in flex in order to control it in a more flexible way.

Starting Point

The main step are:

  1. Make a simple flash project (FLA) with some movieclip
  2. Export it as flex component (SWC)
  3. Import it into flex builder and manage the imported movieclip.

The Flash Side:

Create a new "Flash File (ActionScript 3.0)"
Draw a rectangle and convert it into MovieClip, call it MainMovieClip.
Draw a rectangle inside MainMovieClip
Press F8, convert it into MovieClip, rename it MyMovieClip
Call the MyMovieClip instance into MainMovieClip into "myMovieClip_1"
Save All.

Export it as flex component(SWC)

In order to export the MainMovieClip you have to download the Adobe Flex Component Kit
Inside the downloaded zip you can find a simple mxp, a flash cs3 extension installable by a simple double-click.

Install it and restart Flash CS3.

Reopen the Flash File created in the first step.
Select MainMovieClip
Commands Menu-> Make Flex Component -> confirm the 24fps conversion.

Well, in the output windows you can read, if all is right, Component "MainMovieClip" is ready to be used in Flex.
And a UIMovieClip appears in library window.

In this way the MainMovieClip is converted erediting the mx.flash.UIMovieClip instead of flash.display.MovieClip

Just to make a clear package definition, go to MainMovieClip properities, and change the Class from MainMovieClip in my.test.MainMovieClip

Now by right click again in MainMovieClip export it as swc.

Import the SWC inside Flex and use it

first of all make a new flex project
Add a simple button

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="absolute">
    <mx:Button x="10" y="10" label="Button"/>

Go in the project properities ->  Flex Build Path -> Library Path -> Add SWC ... 
and add the swc exported before.

Now add a as3 script code inside mxml file:


    import my.test.MainMovieClip;
    var mmc:MainMovieClip
    function MainMovieClipShow():void

and add a click event to button:

<mx:Button x="10" y="10" label="Button" click="MainMovieClipShow()"/>

If all is right you see a web page, where by clicking in the button the MainMovieClip appear in the screen.


This simple example show how you can split a project between gui and model.

Java and AMF by AS3 in Flash

The interaction between Java and Flash
(part 2 - OpenAMF)


Download the jar and add the library in the web project.

Make a simple servlet and inside "processRequest" put this instruction

AMFDeserializer amfDeserializer = new AMFDeserializer(new DataInputStream(request.getInputStream()));

System.out.println("bodies String " + amfDeserializer.getAMFMessage().getBodiesString());

See at server.log and you understand that library works, so go deep inside in deserialization

Go to see other details in AMFMessage:

Iterator iterator = amfMessage.getBodies();
                AMFBody body = null;

                while (iterator.hasNext())
                    body = (AMFBody);
                    System.out.println("type description " +     
                    System.out.println("response " + body.getResponse());
                    System.out.println("service method name " +     
                    System.out.println("service name " + body.getServiceName());
                    System.out.println("target " + body.getTarget());
                    System.out.println("value " + body.getValue());
It works also!!wonderful
But Now I want to send an array thru action script:

so in the call funcion I pass an array

var oneArray:Array = new Array("a", "b", "c");"func_name",res,"a_array");

But I obtain the following error: Unknown/unsupported object type UNKNOWN: 0x10001

After some hours I found the problem.
I try to change in as3 client code the AMF encoding:

nc.objectEncoding = ObjectEncoding.AMF0;

And I discover that OpenAMF supports only the AMF0 encoding.
I see also at latest update in sourceforge: 
the date time is 2006 year. It seems and old solution and not maintained.

Switch to see in part3 other solution!

Java, Flash, ActionScript and AMF

The interaction between Java and Flash
(part 1)


I'm writing some notes about the java and flash interaction.
I wish to achieve in the communication between a java web technology and flash client side tecnology

Client Side:

Flex and Flash.
Flex is more powerful with business logic, Flash is the best choose for designers.
See at wikipedia for a little introduction.

Websites using the Adobe Flash Player platform or Flex is programmable by ActionScript language.
Actually the latest version is the 3.0

AMF(Action Message Format) is a binary format for data serialization and remote method invocation. It is for better perfomance, it compress the size of data transferred and it is more powerful than parsing XML data. Basically AMF is the native choose if you want to comunicate with actionscript.


About performance benchmarks are very bright, as you see in this link AMF 3 is the best.
But the webservice is a standard for a scalable architecture. you write a service with soap specification and the you can reuse it in different client technology.
So what about interaction with AS3 and Webservice?

Action Script 3 and Webservice

In the Action Script 2.0 there is a component that allow to consume a webservice.
In Action Script 3.0 it disappears, because now it belong to flex sdk.
So, in order to consume a webservice you need to use a thirdy part component.

I try two thirdy part component, 


But I obtain several error in calling a simple java jax ws "hello world" webservice.
So I think that this component can't handle well the jax ws wsdl and webservice without any further modification.

So, If you want to use webservice you must see Flex within its webservice managed component.
Now I leave this way.

Action Script 3 and AMF

AMF is the easiest way to get communication between flash and the web server.
Data is compressed and is in binary format.

I found an actionscript client code in order to see what data is sent thru amf:

var nc:NetConnection=new NetConnection();


var res:Responder=new Responder(onResult,onError);"func_name",res,"a_parameter");

function onResult(e:Object):void

function onError(e:Object):void

Then I make a simple java servlet in order to see what headers, parameters and body stream is sent.

The content type arrived is application/x-amf
And in the body stream I see the string func_name, a_parameter and other chars, so I think that is the right moment to search for a java amf library for body deserialization.

There are many solutions for AMF in java side:

OpenAMF is a Java port of AMFPHP, it does a small subset of BlazeDS, i.e. Flash Remoting. 

BlazeDS  has a proxy service to proxy HTTP calls, it has an extensive messaging infrastructure with various server push flavors (polling, long-polling, streaming) to build messaging applications, it has JMS capabilities and many different features.

Red5 is a video/audio streaming oriented solution and more close to the Adobe's Flash Media Server. It does  also Flash remoting and remote shared objects which provide limited data connectivity. (BlazeDS does not have video/audio streaming.)

Cinnamon has a full support for AMF4, it works with or without flex, it support spring beans and plain java classes as services, has also an automatic source generation for AS3 service interfaces. Basically is a remoting framework connecting as3 clients with java ee server applications.

Pimento is a framework for integrating data management into RIA. It integrates Java apps, Hibernate, spring with flex,flash and air clients.

Granite DS is an open source framework for integrating Java EE with Flex and AMF3 serialization. It provides interoperability with popular framework service like EJB3, Spring, Google Guice, POJO service etc.

Translate the blog