button onClick

Hi,

I would like to write an expression that will get evaluated when the button is clicked. But when i place the expression in the form's button's onclick property, the expression is getting evaluated before the button is clicked

How do i ensure that it will run only after i click the button?

Yash

[325 byte] By [yash@IDMa] at [2007-11-27 2:11:36]
# 1

following is an example to include a print button on a form which "on click" would print the page

Similarly you have to define an expression

--

<Field button='true'>

<Display class='Button'>

<Property name='label' value='Print Results'/>

<Property name='onClick' value='javascript:window.print()'/>

</Display>

</Field>

post your code i can try debugging it.

nsankar1da at 2007-7-12 2:04:56 > top of Java-index,Web & Directory Servers,Directory Servers...
# 2

Hi,

I don't know why you are not using Derivation tag for this make a refresh button. so when it refresh the form the content of derivation will exicute or you can use javascript also for that.

please tell your requirment in detail so i can do some thing............

Thanx

Shant

Shanta at 2007-7-12 2:04:57 > top of Java-index,Web & Directory Servers,Directory Servers...
# 3

Here is my code....

<Field button='true'>

<Display class='Button'>

<Property name='value' value='OrgHierarchy'/>

<Property name='onClick'>

<invoke name='callMe' class='po.OutputServlet'/>

</Property>

</Display>

</Field>

I would like to invoke the method callMe only after clicking of the button. As of now, it is being called as soon as the form is loaded

yash@IDMa at 2007-7-12 2:04:57 > top of Java-index,Web & Directory Servers,Directory Servers...
# 4

using derivation is fine...

but if you have another action fields, in the same form... it would mess up everything... and function the same way as now.

Hey Yash

I don't see any thing wrong in your code...

Try creating a rule and have that associated to this property "OnClick"

That might be better. Even would allow better testing strategies. test whether your rule is functioning fine too... as well as changes later can also be done easily

Thanks

Nsankar.

Dont forget to update your test results

nsankar1da at 2007-7-12 2:04:57 > top of Java-index,Web & Directory Servers,Directory Servers...
# 5

Hi shant,

I tried by putting the code in derivation and enabled action. But by this, the code is not getting evaluated even after clicking the button..

Shankar,

I wrote the code in a rule and called the rule using the onclick property of the form....in this case, the code is getting evaluated as soon as the form is loaded as earlier(but we want it after clicking of the button). By this we come to know that whatever is written using onclick is evaluated as soon as form is loaded.

Let me know if you want me to test in some other way......as the problem is still not solved.

Also, the environment for testing this problem can easily be setup

Yash

yash@IDMa at 2007-7-12 2:04:58 > top of Java-index,Web & Directory Servers,Directory Servers...
# 6

Shant ,

here is the code for u as stated earlier

<Field button='true'>

<Display class='Button' action='true'>

<Property name='value' value='OrgHierarchy'/>

</Display>

<Derivation>

<invoke name='callMe' class='ko.OutputServlet'/>

</Derivation>

</Field>

Shakar,

Here is the form code for you as stated earlier

<Field>

<Display class='Button'>

<Property name='onClick'>

<rule name='OrgHierarchy'/>

</Property>

<Property name='value' value='OrgHierarchy'/>

</Display>

</Field>

and here is the Rule

<invoke name='callMe' class='ko.OutputServlet'/>

Yash

yash@IDMa at 2007-7-12 2:04:58 > top of Java-index,Web & Directory Servers,Directory Servers...
# 7

Hi Yash,

sorry i was busy in another thing so don't get time to see forum.

Use this code

<Display class='Button' action='true'>

<Property name='value' value='OrgHierarchy'/>

<Property name='command' value='Recalculate'/>

</Display>

<Derivation>

<block trace='true'>

<s>Testing..................................</s>

<invoke name='callMe' class='ko.OutputServlet'/>

</block>

</Derivation>

check that "Testing......................" is print on from load time or after clicking on button. if it printed after clicking on button then i thing it working.

You can call any rule or invoke any java function by onclick property of button u can only call javascript by it.......because any type of calculation can be happen on form at form load time(content of Default tag), refresh time (Derivation content)or after click save ( Expansion content).

Thanx

Shant

Shanta at 2007-7-12 2:04:58 > top of Java-index,Web & Directory Servers,Directory Servers...
# 8

Hi Shant,

I tried out your code but even this doesnt work....the test string is not getting printed(or the invoke function is not getting called) even after clicking the button.

Here is the code i have used

<Field>

<Display class='Button' action='true'>

<Property name='command' value='Recalculate'/>

<Property name='value' value='ExportOrgHierarchy'/>

</Display>

<Derivation>

<block trace='true'>

<s>TestString</s>

<invoke name='callMe' class='ko.OutputServlet'/>

</block>

</Derivation>

</Field>

yash@IDMa at 2007-7-12 2:04:58 > top of Java-index,Web & Directory Servers,Directory Servers...
# 9

Hi Yash,

Please give name to the field like....

<Field name='test'>

<Display class='Button' action='true'>

<Property name='command' value='Recalculate'/>

<Property name='value' value='ExportOrgHierarchy'/>

</Display>

<Derivation>

<block trace='true'>

<s>TestString</s>

<invoke name='callMe' class='ko.OutputServlet'/>

</block>

</Derivation>

</Field>

but Dervation tag is calculated at page load time as well as on recalculate page time also so u have to write some logic so that it will execute ur code at refresh time only like

<Field name='test'>

<Display class='Button' action='true'>

<Property name='command' value='Recalculate'/>

<Property name='value' value='ExportOrgHierarchy'/>

</Display>

<Derivation>

<block trace='true'>

<cond>

<!--some condition>

<s>TestString</s>

</cond>

</block>

</Derivation>

</Field>

Thanx

Shant

Shanta at 2007-7-12 2:04:58 > top of Java-index,Web & Directory Servers,Directory Servers...
# 10
Hi shant,The only question here is how do we write the condition for checking whether the button is clicked or not !!!Yash
yash@IDMa at 2007-7-12 2:04:58 > top of Java-index,Web & Directory Servers,Directory Servers...
# 11

Hi Yash,

there is the code for u...

<Field>

<Display class='Javascript'>

<Property name='script' value='

function shantTest()

{

u=getElement(document.mainform,"dummyfield");

u.value="true"

}' />

</Display>

</Field>

<Field name='test'>

<Display class='Button' action='true'>

<Property name='onClick' value='shantTest()'/>

<Property name='value' value='test'/>

</Display>

<Derivation>

<block trace='true'>

<cond>

<notnull>

<ref>dummyfield</ref>

</notnull>

<s>TestString</s>

</cond>

</block>

</Derivation>

</Field>

Thanx

Shant

Shanta at 2007-7-12 2:04:58 > top of Java-index,Web & Directory Servers,Directory Servers...
# 12
sorry forget to add this one..... <Field name='dummyfield'><Display class='Hidden'/></Field>
Shanta at 2007-7-12 2:04:58 > top of Java-index,Web & Directory Servers,Directory Servers...