Support > Repository > Function > External cooperation

We introduce four functions on cooperation with external system.

HTTPSEND (character string indicating url)

We will access the (external) site shown in url and get page information.

HTTPSEND("http://wagby.com")

By specifying the REST API server that returns JSON to the url part, it can be used to acquire external values.It is assumed to be combined with the JSONPATH function described later.

This method supports HTTP GET only.You can not use it for applications such as POST and PUT.Also, you can not specify the request header etc.

ISREST()

If the current interaction is via the REST APItrue.Otherwise (operation from the screen or upload update, download etc.)false.

JSONPATH (String containing JSON object, JSON Path string)

It parses the string in JSON format and gets the value specified by JSON Path.

JSONPATH(${jsondata},"$.Items[0].Item.title")

In the above example, JSON data set in the jsondata item is analyzed and the title is acquired.

JSON Path is "Java JsonPathI'm using a library called.http://jsonpath.curiousconcept.com/So you can try JSON Path's behavior.

REQUEST()

REQUEST ("name")

This function is assumed to be used in the case of POSTing to Wagby from a Web form prepared on a system different from Wagby (eg a form prepared by PHP, Perl, etc.).

Gets a value from the request object managed by Java with the specified name. When transitioning from pages other than Wagby, you can receive HTTP GET/POST parameters directly.The return type is a string type.

REQUEST("id")

If the name sent from the Web form matches the name (English) of the target item, the argument of the REQUEST function can be omitted.

The return type of the REQUEST function is a string type.To set this value to numeric type or date type item, please convert from character string to numeric value and date using TEXT function etc.

(Type) SESSION ()

(Type) SESSION ("Name")

This function is provided for those who develop customized Java.

Gets a value from the session object managed by Java with the specified name.Since the return type is arbitrary, be sure to specify the type explicitly.

(String)SESSION("item1")

If the key name of the session object matches the name of the target item (English), the argument of the SESSION function can be omitted.

The SESSION function can be used by developers to "customize" Java code and "receive" values ​​stored in session objects.When you receive a value, be sure to cast it with the type of object stored in the session object.(If you do not specify a type or specify an incorrect type, an error will occur at compile time.)

Supplement for type

The relationship between the object to be stored and "type" is as follows.

Object to store How to describe "type" to specify
Integer type(Integer)
String type(String)
Date type(java.sql.Date)
Time type(java.sql.Time)
Date Time Type(java.sql.Timestamp)
File type (file name)(String)
1 byte integer(Byte)
2 byte integer(Short)
4 byte integer(Integer)
8 byte integer(Long)
4 byte floating point number(Float)
8 byte floating point number(Double)
Fixed value (creation date/update date)(java.sql.Timestamp)
Other (URL type/mail address type etc.)(String)

(Type) ATTRIBUTE ("name")

Every time it executes a single process (communication occurs with the server as a result of a user pressing a button or the like and the screen of the browser is rewritten after the process on the server is over), the object "p.request" It is generated.It will be discarded when processing is completed.In other words, the "lifetime" of the p.request object is from the start to the end of a single process.

The ATTRIBUTE function gets the value stored in this p.request.To specify the type of return value, specify type before ATTRIBUTE function.The relationship between objects and types Same as SESSION function descriptionis.

Set the value to p.request

To store "value" in this p.request object, use p.request.setAttribute method.The argument is the key name (character string) and the object you want to store.This function is not provided.Make sure to set the value using a script.(Application example: Display the child model list using item values ​​other than the parent key)