Saturday, December 16, 2023

Dojo - Nov 15, 2023 -- Developing a React Native App

In this dojo the team experts on mobile development gave us a rundown on setting up a development environment using React Native and Expo.  These are the developers assigned to the Go & Give team.  This project is a native mobile app distributed to both Apple and Google app stores.  

Additionally, the app is zipped up and hosted on the CloudPiston platform with a wildcard cert and domain.  Each organization has their own branding and subdomain, configured by an administrator within the platform.

The codebase, amazingly, works both as a web app and a native app installed via the app store.

Watch the video here:

React Native Dojo Video



Saturday, November 17, 2012

Ajax Fundamentals

Instructions for no-frills AJAX.

1) Create anchor tag and add ajax-target which points to the location where you want the result displayed.
2) Create the target tag.
3) In workflow, create and return an AjaxResponse using static or dynamic content.
4) If your response includes a <c:document/> tag, make sure you add the document onto the AjaxResponse so any changes to the document are visible.  Otherwise you'll be looking at the cached document.

In the page/fragment:

<c:a action="yourAction" ajax-target="yourTarget">click me</c:a>
<br/>
<div id="yourTarget"></div>


In workflow
return c.createAjaxResponse(c.getPal().getAjaxFragment("yourContent"),true);


or if you're dealing with a document update

var pal=c.getPal();
var doc = packet.getFirstDocument();
var frag=pal.getAjaxFragment("yourContentWithDocumentTag");
var response=c.createAjaxResponse(frag,true);
response.addDocument(doc);
return response;

Calculating Image (PNG) Size

There are a couple of APIs that create an image, usually from a PDF.  The formula below helps you determine the size of the resulting image.  This is important as you might be dealing with a restricted Activation Key that protects your billing amount.  Bottom line- use your head and don't create images larger than you actually need.

The formula:
PNG Size = N*P*S^2
N=Number of pages (typically N=1 if you are creating an image of a single page).
P=Page size which depends on what is in the page (how much content).  We'll use the maximum possible which is:
P=WxHxC(bytes)=Width of page in pixels x Height in pixels x C (C=1 for grayscale, 4 for color) in bytes at scale=1.0

A normal 8.5x11 page at scale = 1.0 (100%) is 611 pixels by 791 pixels.  So P = 611x791x4=1,993,204 or about 2MB for color or about 472KB for grayscale.

So the biggest a PNG page at scale 1.0 will be is 2MB.  The max allowed scale is 3.0.
At this level, the max PNG will be 1*2MB*9=18MB!

Since most activation keys are limited to 6MB, your max scale would be:
S=sqrt(6MB/2MB)=sqrt(3MB)=1.73.

Conclusion- make sure your key has at least 2MB max upload and think twice about going over 1.0 for scale.

Credits:
Thanks to SoftServe for providing the above information

Here is an example API that such conversation applies to:
https://secure.cloudpiston.com/cpal/cp-api/console/PdfFile.html#80AD098E019FA7775F8AD0487D5424DD
   

Why?

Each day our team works on ContractPal's CloudPiston platform, I keep wondering how we are ever going to get caught up on all the documentation, sample code, best practices, code techniques, and dozens of other things that developers need to take advantage of a platform.

This blog is the short answer to that question.

For our team members who need cutting edge answers, when they need it, as opposed to when its first available- this blog provides a reference.


Goals for this blog:

  1. Documentation, notes, comments- while they are fresh.
  2. Answers to public questions.
  3. Links to useful stuff.