accessing UI Page variables in Processing script to insert a record without glideAjax

lalit007
Tera Contributor

Hi,

below is my ui page code:-

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<h2 >Add a new Dog</h2>

<j:set var="jvar_shots" value="false"/>

<j:set var="jvar_neutrd" value="false"/>

<g:ui_form>  

<table>

<tr><td>Name of dog</td><td><input type="text" name="nameOfDog" /></td></tr>

<tr><td>Age of dog</td><td><input type="text" name="ageOfDog" /></td></tr>

<tr><td></td> <td><input type="checkbox" name="shots" />Shots</td></tr>

<br>

<tr><td></td> <td><input type="checkbox" name="neutrd" />Neutered</td></tr>

</br>

</table>

<j:if test="${shots}.checked()">

jvar_shots =="true"

</j:if>

<j:if test="${neutrd}.checked()">

jvar_neutrd =="true"

</j:if>

<input type="submit" value="Add Dog"></input>

</g:ui_form>  

</j:jelly>

Processing script is as below:-

gs.addInfoMessage("In Processing Script"+nameOfDog+"   "+ageOfDog+" "+jvar_shots+" "+jvar_neutrd+" ");

var gr=new GlideRecord('x_165904_dog_adopt_dogs');

gr.initialize();

gr.name= nameOfDog;

gr.age= ageOfDog;

gr.shots= jvar_shots;

gr.neutered= jvar_neutrd;

gr.insert();

gs.addInfoMessage("Dog Number Is =>"+gr.number);

response.sendRedirect("/x_165904_dog_adopt_dogs_list.do");

unable to assign value to gr.shots and gr.neutered.

Error is as below:

org.mozilla.javascript.EcmaError: "jvar_shots" is not defined.

    Caused by error in sys_ui_page.57c993370f120300ad42b97ce1050e4a.processing_script at line 1

2 REPLIES 2

Tommy LaMonte
Tera Expert

Don't use jvar_shots. The variable would just be "shots".



In processing scripts you can access the form values by name directly.


Thanks for the reply Thomas,



i know in processing script we can access the variables directly as you can see i have used nameOfDog and ageOfDog   variables directly but i am doing some validation on the ui page then using the values on the processing script...


i am validating, is the Shots field and Neutered field   is checked by the user or not, if it is checked then i am passing true values for both to the processing script, is there any other way to validate this then please tell me.



regards,


Lalit bhatt