Before you proceed, make sure to create the example workspace as described here.
Create the UI
Open the example workspace in the Profound.js IDE by pointing your browser to a URL formatted as follows:
- Name the screen "helloworld"
- Drag the a Panel onto the Visual Designer canvas
- Double-click the panel title and type "Hello World"
- Drag a Button to the canvas, double-click the button and change the text to "Continue"; then set other button properties as desired
- Bind the button's response property to a Boolean Indicator field named "continue"
- Save your work to /profoundjs/modules/pjshello/example2.json (replace /profoundjs with your Profound.js installation directory)
Create Node.js server-side logic
Next, you will create the Profound.js module named example2.js:
The code uses the pjs.defineDisplay() API to declare a JSON display file and create an object named "display". Every screen within the Rich Display becomes a property of the "display" object. The display.helloworld.execute() method shows the screen to the user and waits for the user to respond.
Set Up a Named Route To Run the Program
Configure the example2.js file as a Named Route (stateful), as described here. Set the route path to example2.
Try the Application Using the Named Route
Open a browser and navigate to the following URL:
That's it! You created a Hello World application with Node.js. If you're developing for the IBM i platform, proceed to the next step.
Try the application using PJSCALL on IBM i
Now, start a Genie session by navigating to the following URL:
Note, if you are testing and creating Profound.js modules on your PC, you can use the PJSMYIP command before running PJSCALL to point Genie to the Profound.js installation on your PC.
Try the application using a Proxy Program on IBM i
Using a Proxy Program object allows you to call your Node.js application with a standard IBM i CALL.
Expand the application to use dynamic fields
In the Visual Designer, follow the steps:
When you rerun the application, you will see some new functionality. The number increases every time you click Continue and the script ends when you click Exit.
Make your application call an interactive command on IBM i
Let's add another button to your screen and label it "Active Jobs". Bind the button's response property to a Boolean Indicator named "activejobs" and save your work.
You can interact with the screen as necessary. When you exit the Work with Active Jobs screen, you will return to your Node.js Hello World interface.
Displaying information in grids
Let’s add a grid of information to the screen.
The output will look as follows:
Processing input from the grid
Next, add elements to the screen to show selected records:
At runtime, after you select some records and click the Continue button, you should see output that looks like this:
Working with grid records in bulk
So far, we have worked with grid records one at a time. In the code above, each record is written and read individually. Using the various Grid API, it is also possible to work with records in bulk. The following accomplishes the same task as above, but with less lines of code: