K
Klaas van Gelder
Hi all,
I have a form (html:form) which dynamically displays a number of
database records prefixed by a checkbox (html:multibox).
The user can select a number of records and carry out some action for
the selection. The number of possible actions is also dynamic and is
determined by the call:
userData.getHandler().getButtonsToShow()
For each of the possible actions, I include a submit button
(html:submit) in the form. The use of multiple submitbuttons is
necessary because of the checkboxes which also must be included within
the form (otherwise separate forms for each submit button could be
used). So now I need a wayt to indentify each submitbutton uniquely for
the Struts action.
The only way I can think of to achieve this is the use of a hidden
field, here with property="aktieVoorSelectie". The value of this
property is set with a Javascript function (zetAktie), which receives
the "key" of the pressed button as an argument.
But this code does not work !!! The scriptlet <%=key.toString() %> is
not translated but appears literally in the generated HTML source !
the code DOES work if a static number is passed to the JS function.
The real problem is that the submit buttons are created
on the fly, because the number of possible actions is
determined by a call to some business method.
Therefore, I need to pass an argument to the Javascript-function
dynamically. I try to use a scriptlet for this, and that is
where the problem arises !!!
The scriptlet in the JS function argument is not resolved
but appears literally in the generated HTML !
So my real question is: is there a method to pass the value of
key.toString() to the JS function ?
Greetz,
Klaas
<html:form action="/DoSomething">
<html:hidden property="aktieVoorSelectie" value=""/>
<%
//loop over knoppen
int[] knoppen = userData.getHandler().getButtonsToShow();
for (int i=0; i<knoppen.length; i++) {
Integer key = new Integer(knoppen);
%>
<html:submit
styleClass="button_blue"
value="<%= optionDataBean.getAktieButtonData(key).getCaption() %>"
title="<%= optionDataBean.getAktieButtonData(key).getAltText() %>"
onclick="zetAktie(<%=key.toString() %>)"/> <% //THIS LINE DOES
NOT WORK
}
%>
</html:form>
I have a form (html:form) which dynamically displays a number of
database records prefixed by a checkbox (html:multibox).
The user can select a number of records and carry out some action for
the selection. The number of possible actions is also dynamic and is
determined by the call:
userData.getHandler().getButtonsToShow()
For each of the possible actions, I include a submit button
(html:submit) in the form. The use of multiple submitbuttons is
necessary because of the checkboxes which also must be included within
the form (otherwise separate forms for each submit button could be
used). So now I need a wayt to indentify each submitbutton uniquely for
the Struts action.
The only way I can think of to achieve this is the use of a hidden
field, here with property="aktieVoorSelectie". The value of this
property is set with a Javascript function (zetAktie), which receives
the "key" of the pressed button as an argument.
But this code does not work !!! The scriptlet <%=key.toString() %> is
not translated but appears literally in the generated HTML source !
the code DOES work if a static number is passed to the JS function.
The real problem is that the submit buttons are created
on the fly, because the number of possible actions is
determined by a call to some business method.
Therefore, I need to pass an argument to the Javascript-function
dynamically. I try to use a scriptlet for this, and that is
where the problem arises !!!
The scriptlet in the JS function argument is not resolved
but appears literally in the generated HTML !
So my real question is: is there a method to pass the value of
key.toString() to the JS function ?
Greetz,
Klaas
<html:form action="/DoSomething">
<html:hidden property="aktieVoorSelectie" value=""/>
<%
//loop over knoppen
int[] knoppen = userData.getHandler().getButtonsToShow();
for (int i=0; i<knoppen.length; i++) {
Integer key = new Integer(knoppen);
%>
<html:submit
styleClass="button_blue"
value="<%= optionDataBean.getAktieButtonData(key).getCaption() %>"
title="<%= optionDataBean.getAktieButtonData(key).getAltText() %>"
onclick="zetAktie(<%=key.toString() %>)"/> <% //THIS LINE DOES
NOT WORK
}
%>
</html:form>