facebook

iPhone ME4S running on Apple’s iPhone Simulator

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #310775 Reply

    I am having a problem with ME4S’s iPhone support. Here is what I did:
    1) New Web Project — generate CRUD for both Spring MVC and iPhone
    2) Open up Apple’s iPhone simulator (comes free with Apple’s XCode).
    3) Paste the URL into the iPhone simulator’s Safari web browser:
    http://new-host.home:8080/testwebandiphone1/
    4) The web application comes up and works perfectly in Apple’s iPhone simulator except for one problem: it shows the Spring MVC version, not the iPhone version.

    Suggestions appreciated. I am obviously missing some key point here. The web page that displays in Apple’s iPhone simulator shows the “Spring MVC” button and then underneath that it says,

    :An iPhone application has been generated but you will need to use either an iPhone or an iPhone emulator to view the application. Use the following URLs to access the generated application:

    Employees – http://new-host.home:8080/testwebandiphone1/indexEmployee

    But when I put that address into the iPhone simulator, the page that appears (the employee listing) looks EXACTLY the way it looks if I simply put that same address into a normal Chrome or Safari browser on my Mac.

    #310776 Reply

    Addendum: It dawned on me that ME4S was using MobiWeb, so I went to http://www.genuitec.com/mobile/ to download their free iPhone simulator (thinking perhaps it will work better than the actual Apple iPhone simulator).

    However, on the MobiWeb download page it says that MobiWeb is a windows-only application.

    So I’m struck. On Apple’s iPhone simulator the Iphone app generated by ME4S looks like a normal, non-iPhone application, and the iPhone simulator that ME4S (apparently) recommends does not work on a Mac. I am using ME4S on a Mac.

    #310782 Reply

    Heflin Hogan
    Member

    The Apple iPhone simulator should definitely work. I’ll have a look and see why it isn’t, but in the meantime, have you tried enabling the Dev tools menu on Safari and changing the user agent?

    Regards,
    Heflin

    #310799 Reply

    @hhogan wrote:

    …, have you tried enabling the Dev tools menu on Safari and changing the user agent?

    That sounds like a great idea. However I am looking in Safari on my Mac and cannot find an option to enable Dev tools. It is Safari version 5.0.1. Do I need to download a Safari extension? I don’t see anything in Safari preferences or in the menus related to Dev Tools.

    #310802 Reply

    Heflin Hogan
    Member

    No extension, there’s an option on the Advanced preferences:

    http://macs.about.com/od/usingyourmac/qt/safaridevelop.htm

    #310803 Reply

    @hhogan wrote:

    there’s an option on the Advanced preferences:

    http://macs.about.com/od/usingyourmac/qt/safaridevelop.htm

    Thanks.. will try as soon as I get home tonight. The user agent does seem to be the key to this. In looking at the ME4S source code, I see it looks for the iPhone user agent, and if so uses a special view resolver. In addition to simply using the Apple iPhone simulator, I also compiled and ran an Apple sample program (written in Obejctive C) that creates an iPhone app that goes to whatever web site URL is typed in. That, too, showed the non-iPhone version of the website when I typed in the address of the ME4S CRUD program that has both Spring MVC and iPhone CRUD.

    Incidentally, it was my experience that I needed to generate both Spring MVC and also iPhone CRUD into the same project. I.e., my results were (even) less satisfactory when I only generated iPhone CRUD but not Spring CRUD. Perhaps that too is related to the user agent. I.e., that I have not been able (apparently) so far to send a user agent of “iPhone” from a client browser to the ME4S CRUD application.

    #310807 Reply

    Heflin Hogan
    Member

    Have you upgraded to the GA version of 8.6? The text you cited in the original post is from the Milestone releases.

    #310808 Reply

    @hhogan wrote:

    Have you upgraded to the GA version of 8.6? The text you cited in the original post is from the Milestone releases.

    I thought I upgraded to GA 8.6 but will check again when I get home. I remember having a slight problem trying to figure out where ME4S had installed itself. Maybe the GA version installed itself into a different location than the prior non-GA version. Just a theory at this point however.

    #310816 Reply

    It turns out to be true that I was using ME4S 8.6 M2 instead of ME4S 8.6 GE. Good catch!
    After re-installing ME4S I recreated the iPhone/Spring MVC CRUD project.
    Then I activated the “Developer” tab in Safari.
    Here are the results:

    When I set agent to “iPhone” (on Developer tab of Safari) the web app correctly looks like an iPhone web app.

    When I set agent to “iPod” or “iPad” the web page does not look like an iPhone web app, it looks like a normal web page.

    When I use the iPhone simulator that comes with XCode and use the Safari browser that is inside the simulator, the web page looks like a normal web page, not like an iPhone app.

    #310842 Reply

    When I use Safari developer tools to set agent header to iPhone it displays:

    user-agent= 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 Safari/528.16'
    

    and when I set the agent type to iPad it displays:

    user-agent= 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10'

    and when I set the user agent in Safari dev tools to iPod it displays:

    user-agent= 'Mozilla/5.0 (iPod; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 Safari/528.16'

    and when I use the Safari browser that is a little icon with the Apple XCode iPhone simulator it displays:

    user-agent= 'Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_0_2 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A400a Safari/6531.22.7'
    #310845 Reply

    Heflin Hogan
    Member

    Nice! That makes the troubleshooting easy. I’ll need to enter an issue to get the user agent string we are emitting changed, but you can make the modification yourself in the meantime. In the generated web context resource, there is a bean that should look like this:

    
    <bean id="iPhoneUserAgentViewResolver" class="org.skyway.spring.util.viewresolution.UserAgentViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
            <property name="agentSubstring" value="iPhone; U" />
            <property name="prefix" value="/WEB-INF/iphone/" />
            <property name="order" value="0" />
    </bean>

    You can simply modify the agentSubstring property to “iPhone”, and it will pick up the simulator. I believe a similar approach would work for iPad/iPod, but I haven’t tried that out.

    Regards,
    Heflin

    #311264 Reply

    I added a YouTube video to my YouTube channel ( http://www.youtube.com/robertgloverjr ) that is relevant to this thread.

    Is is entitled: MyEclipse for Spring iPhone scaffolding
    http://www.youtube.com/watch?v=CyA0nM4PxHA

    In creating the YouTube video, it occurred to me to wonder as I was making it, that the class used for the iPhone view is:
    org.skyway.spring.util.viewresolution.UserAgentViewResolver

    Is it okay to use skyway provided classes such as the one above with the same legal confidence that one can use “real” Spring classes? For example, are only developers who have purchased a ME4S licence allowed to use classes like this one in their applications? What happens if classes such as the one above become part of a production web application that is developed in the future with plain Eclipse or with, for example, IBM RAD instead of with MyEclipse? Are the jar files containing these skyway classes legal to use in these scenarios? Is it okay to modify the source code of these classes?

    Another question I have, is whether it will work to replace

     <property name="agentSubstring" value="iPhone; U" /> 

    with a list of user agents. This would be very useful to support iPod, iPhone, and iPad. Otherwise I guess the user agent value would need to be “iP” which seems like a bad idea because there might be other devices that would be included.

    #311274 Reply

    davemeurer
    Member

    Hi Robert,

    Is it okay to use skyway provided classes such as the one above…

    Absolutely! The output of ME4S is pure Java code that runs within the Spring Framework. As you would expect though, there are a few classes that the generated code references which were created by Skyway. These classes are licensed under the Apache Software License (ASL). The great thing about ASL is that there are very few redistribution restrictions. This means that applications that you create with Skyway Builder CE can be redistributed and sold even under your own commercial software license.

    Regarding the user agent question, let me get back to you on that one.

    Kind regards,
    Dave[/url]

    #311275 Reply

    @davemeurer wrote:

    …. there are a few classes that the generated code references which were created by Skyway. These classes are licensed under the Apache Software License (ASL). ….. applications that you create with Skyway Builder CE can be redistributed and sold even under your own commercial software license.

    That is good news. I also note (with approval) that when I right click on skyway classes within ME4S and choose “Open Declaration” the java source code of the skyway classes appears for me to view and study. The skyway source code looks to me to be very well written and documented with thorough, understandable JavaDoc comments.

    #311277 Reply

    davemeurer
    Member

    Hi Robert,

    Regarding:

    Another question I have, is whether it will work to replace

     <property name="agentSubstring" value="iPhone; U" />

    with a list of user agents. This would be very useful to support iPod, iPhone, and iPad. Otherwise I guess the user agent value would need to be “iP” which seems like a bad idea because there might be other devices that would be included

    Take a look at a blog Cindy wrote on Mobile Spring-Based Web Apps for Everyone. Specifically, page 4 where she gives an example of using other agentSubstrings. You’ll need to add a new user agent view resolver definition for each agent you want to re-direct. The value supplied must be a substring of the user agent header so you can’t add them all in one definition.

    HTH,
    Dave

Viewing 15 posts - 1 through 15 (of 16 total)
Reply To: iPhone ME4S running on Apple’s iPhone Simulator

You must be logged in to post in the forum log in