Tag Archives: XHTML

Getting creative with UIWebView and NSURLProtocol

via Oyster Engineering — Getting creative with UIWebView and NSURLProtocol.

Every iOS developer should be familiar with UIWebView. Introduced all the way back in 2008 as part of iPhone SDK 2.0, developers have used (and abused) this versatile class for everything from displaying remote web pages to building entire apps. While the vast majority of Oyster for iOS is built using native code, we do rely on UIWebView for one crucial task: rendering books.

Here’s a little background: when we started building Oyster, we knew web content would play a central role in the way users would interact with the app. Like many e-book readers, ours needs to work with EPUBfiles, which are essentially zip archives containing XHTML, binary resources, and XML metadata. We started using UIWebView out of convenience—it was a boon to our early prototyping phase, making displaying a book in an iOS app as easy as loading a web page. After evaluating more sophisticated options specifically geared toward rendering EPUBs, we decided to continue developing our simple UIWebView-based prototype into our own fully functional rendering engine.

Today, we’d like to share one of the techniques we’ve employed to use UIWebView to our advantage. Namely, we’ll talk about how we’ve built our EPUB rendering engine on top of the relatively obscure yet powerfulNSURLProtocol class. As we’ll demonstrate, NSURLProtocol makes it possible to load just about anything, from anywhere, into a UIWebView.

To illustrate the capabilities of NSURLProtocol, we’ll implementZIPURLProtocol, a subclass that will enable us to load and display HTML pages from a zip archive on the fly using the delightful zipzap library.

Available Resource: Front-End Web Developer/ Designer

Click to Download resume/ C.V

Paul Castillo Mora is Front-End Web Developer/ Designer has 9 years of IT Industry experience. His current location is Costa Rica and He is willing to relocate anywhere in USA, Canada, France. He is looking out for Work Sponsorship and he is available Immediately. If interested please E-mail him at pk2castillo@gmail.com or call him at (+506) 88169851

His area of expertise:
Front-End: XHTML / HTML5, CSS2.1 / CSS3/ JavaScript/ Yeoman/ Laravel/ Progressive Enhancement/ Website Speed Performance/ Responsive Web Design/ CSS Frameworks (Foundation, Skeleton, Bootstrap)/ WordPress / Photoshop CC / Illustrator CC / Git / SASS / LESS / UI Prototype / UX Experience / Mobile Web Development/ Responsive Email Design & Development
Design: Photoshop, Illustrator, Indesign
Motion Design: Cinema 4D, After Effects

How to get JSON response from JSF?

How to get JSON response from JSF?

Many JavaScript widgets expect data and options in JSON format. Nowadays, it is really easy to choose a cool widget and wrap it in a composite component. But the first question is how to send an AJAX request and to recieve a response in a proper JSON format. This question is often raised by JSF users. All what you need is a XHTML facelet like this one

<f:view encoding="UTF-8" contentType="text/html"
  <h:outputText value="#{stationView.getClosestStations(param.longitude, param.latitude)}" escape="false"/>

Please consider the contentType=”text/html” (application/json will not work here) and escape=”false” in theh:outputText. The method getClosestStations() in the bean StationView produces an JSON output for a list of special Java objects. I advise to use the Gson library in order to serialize any Java object to JSON. Short example: