Friday, February 8, 2008

IdcoScript vs Javascript

I'd like to explain the difference between IdocScript and Javascript because it is an important step for template pages in Oracle Content Server.

IdocScript is a server scripting language created for Oracle Content Server (formally Stellent Content Server) template pages. It consists of the basic functionality you need to create pages that display content or execute services. We should note IdocScript is designed only for the content server.

Javascript is a client side scripting language, that is executed by the client browsers. Javascript is used for form validations, and for making dynamic display of HTML elements. Javascript. Javascript cannot execute a service or retrieve results from the content server.

The idea is we use IdocScript for executing services and core functionality whether by standard functions, or by custom functions which are a java methods. Which means separating business logic. While Javascript is for the user interface, by Javascript we create functions for validating input data, and creating user friendly user interface. Which means separating user interface design from business logic.

<$i=1$>
<$loop tempResultSet$>
<tr>
<td><b><$i$></b></td>
<$i=i+1$>
<td><$col1$></td>
<td><$col2$></td>
<td>
<input type="button" value="click me" onClick="alert('<$col3$>');window.close()">
</td>
</tr>
<$endloop$>

Here in this code I have a result set called tempResultSet which consists of three columns (col1, col2, and col3), and I loop on this result set to display its values by just getting columns values <$col1$> and <$col2$>, but I need one more thing I need to have a button when it will be clicked, a pop up message with 'col3' value appear which is a Javascript functionality and cannot be done using IdocScript where Javascript can put event listener functions or code to HTML form elements like what we did above onClcik="alert('<$col3$>');", but in the alert method we need to display col3 value, so we just add IdocScript code that return col3 value.

How that thing is done, when I user requests the page contains that code, the request is passed to the web server, and the web server requests that page from the content server, the content server finds the template page which contains IdocScript code and Javascript code, in that point the content server executes the IdocScript code only which returns either HTML code or Javascript code, then the page is sent to the web server which will send it to the client with no Javascript code.

I think that explain gives you a complete picture about what happen, but I need to explain it more.

When The content server searches for the template page, it will find it like

<$i=1$>
<$loop tempResultSet$>
<tr>
<td><b><$i$></b></td>
<$i=i+1$>
<td><$col1$></td>
<td><$col2$></td>
<td>
<input type="button" value="click me" onClick="alert('<$col3$>');window.close()">
</td>
</tr>
<$endloop$>

Then the content server execute the IdocScript code before sending it the webserver, the above code will be changed to

<tr>
<td><b>1</b></td>
<td>value 1-1</td>
<td>value 1-2</td>
<td>
<input type="button" value=""click me onClick="alert('value 1-3');window.close()">
</td>
</tr>
<tr>
<td><b>2</b></td>
<td>value 2-1</td>
<td>value 2-2</td>
<td>
<input type="button" value="click me" onClick="alert('value 2-3');window.close()">
</td>
</tr>

and also the client will get the same result.

I wish this helps you in understanding the interaction and the isolation between IdocScript and Javascript.

12 comments:

Vinod Kumar Kashyap said...

How can we get value of javascript variable in idoc script

Hisham Galal said...

You cannot do that, because Javascript is being executed on the client side by the browser and Idocscript is being executed on the server side.

Where at the start the user requests a page which contains Idocscript and javascript, the server didn't understand Javascript but it understands Idocscript so it will execut Idocscript code, then the server will send the response page to the user browser with no Idocscript code, there will be javascript code which will be executed by the browser.

nash said...

Hi When I try to execute a workflow, which is having an custom script at its entry point as <$if wfAction like "REJECT" $>.. I am getting an error - Could not find the parameter wfAction.. What can be the problem? Please help me asap?..

Thanks
Noushad
emperor333@gmail.com

Hisham Galal said...

did you tested it by workflow test?

nash said...

Yes Hisham I tested it and then only could find the error is with the Idoc Script piece..?

Hisham Galal said...

can you post the full script written?

nash said...

Hi Hisham,


Let me explain actual issue for me which led me till Test tab of workflow.

Actually I went into customize a simple workflow which only posses 4 steps



Step1: A checkin some file

Step2: B reviews it and REJECTs it so should go to step 4 or approves continue with step 3

Step3: C reviews and approves

Step4: D reviews and resubmit to B(step2).





I created workflow with these steps and when in step2 the userB REJECTS i am checking with the idoc script in entry step of Step3 <$if wfAction like "REJECT" $> jump to step4 but here its not getin into the script check instead it goes back to step1(Contributor).



How can i acheive this?



Is this because the step needs to be altered to reviewers (read somewhere)? and if so where do I modify?




Thanks,



Noushad

nash said...

Email followup added!

Hisham Galal said...

try to use single quotes instead of double quotes

<$if wfAction like 'Approve'$>
.......
<$endif$>

Hisham Galal said...

I need your full script to test it

nash said...

Thanks Hisham!

I solved my issue by introducing one rejection handler step! This information is there concealed in oracle workflow documentations..!

Thanks for your help..
Noushad

jellenac said...

Hello Nash!

Could you please tell me how did you solve your problem, because, i got similar error.

Here is my script <$if wfAction like "APPROVE"$>
<$wfSet("wfJumpName", "Prelazak_u_Risk1")$>
<$wfSet("wfJumpTargetStep", wfCurrentStep(1))$>
<$wfSet("wfJumpReturnStep", wfCurrentStep(0))$>
<$wfSet("wfJumpEntryNotifyOff", "1")$>
<$endif$>


Thx!