Calling an O4W Proceedure using Http (O4W)
At 07 JUN 2011 07:11:56AM Richard Bright wrote:
On Page 252 of the 9.2.1 Reference Manual the declaration form for calling forms, repots etc is set out. For an O4W Procedure -
IV. Calling an O4W Procedure
http://localhost/examples/oecgi2.exe/O4W_PROCEDURENAME
So how do I pass the O4W Procedure parameters ie Ctrl,Event,Request?
At 07 JUN 2011 07:32AM Dave Harmacek wrote:
I use
/O4W_PROC?O4WEvent=text
succesfully. Try O4WCtrl.
For Request your own arguments follow standards
&ARG=argtext&ARG2=arg2text
Dave OI Blog at http://www.harmacek.com
At 07 JUN 2011 02:19PM bshumsky wrote:
Hi, Richard. You don't, explicitly, control what gets passed in via the three parameters to your O4W stored procedure. The O4W framework handles setting those values before your routine is called.
In your stored procedure, you examine any passed-in parameters (either encoded in a form, or via named/value pairs in the URL) via O4WGetValue.
As Dave has indicated, you can put these on the URL, using "?" to initially delimit the name/value pairs, and "&" to delimit additional name/value pairs. For example:
http://localhost/examples/oecgi2.exe/O4W_PROCEDURENAME?MyParam1=myalue1&MyParam2=myvalue2
You could then examine the value of these passed-in parameters with:
val1=O4WGetValue("MyParam1")
val2=O4WGetValue("MyParam2")
In this example, since you're pulling this information right off the URL, this would probably go in your code to handle the 'create' event. The fact that this _is_ the create event is determined by O4W, and passed in to your stored procedure parameters automatically.
Similarly, if you had specified that there should be a 'click' event on a button, O4W will automatically (when the button is pressed) send in 'click' as the event, and the id of the button as the control; you can then examine parameters that were entered (for example, in a form) at that point with O4WGetValue.
Hope that helps clear things up a little.
Regards,
- Bryan Shumsky
Revelation Software
At 08 JUN 2011 08:04AM Richard Bright wrote:
Thanks Bryan and Dave.
With that information I was able to get the http call working.
My confusion was that - with the http call - I thought I needed to pass the first two parameters - Ctrl and Event; as pointed out this is handled by the system - just needed to pass the values, in this case I am passing Database, Table and Keys using the MyParam1=Value1&MyParam2=Value2&MyParam3=Value3. To enable the proceedure to be called conventionally AND via Web reference I had to test the Request value thus:
If Index(Request,'Database=,1) Then
Line=Field(Request,@fm,1)Convert '&= To @fm:@vm In LineDatabase=Extract(Line,1,2,0)Table =Extract(Line,2,2,0)RecordID=Extract(Line,3,2,0)
I may have multiple record keys so have used delimSwap '%7C' with @vm In RecordIDEnd Else
Database=Field(Request,@fm,1)Table =Field(Request,@fm,2)RecordID=Field(Request,@fm,3)End
As I have found - this is not a great way to jump to associated windows because of length constraints of passing multiple record keys in the Http request. However it is has got the job largely done.
Now with the concept working I can focus on refining and replacing the hack code with better O4W components.
Thanks guys.
Richard Bright