As I’m not a javascript nor a jsf expert, I ask if it is possible to define a global variable and then pass it as a parameter for an action-bound method.
Maybe it is more clear with an example… 🙂
In my xhtml code should be something like this:
...
<script type="text/javascript">
var isEdit = "false";
//<![CDATA[
function editSelected(selBox, inputFiled)
{
var htmlstring = selBox.options[selBox.selectedIndex].text;
inputFiled.value = htmlstring;
isEdit = "true";
}
//]]>
</script>
...
<h:commandLink
styleClass="waiButton"
value="#{lakshmiMsg.commonButtonAdd}"
action="#{detailController.addCreator(**isEdit**)}"
rendered="#{detailModel.mode != detailModel.viewMode}">
</h:commandLink>
...
Would be something like this possible?
If not, are there maybe other ways?
You could alter a hidden input field by JS. E.g.
with
An alternative is to just don’t do the
editSelected()job in JS, but instead do the job in pure JSF with<f:ajax>magic. As the functional requirements for this are not clear because the code is incomplete and not self-documenting enough, I can’t give a kickoff example for that.