Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getting forceId in h:commandLink  RSS feed

 
Udit Manektala
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im using an IBM implementation of JSF and need to disable a command button after it is clicked so that the user can't click it again until the page is refreshed. Doing a this.disabled='disabled' in the onClick event doesnt work because once the button is disabled, the submit button wont submit anymore.

So we thought, we'd make the submit button a regular button and put some kind of form.submit in the onClick. So we made a clickLink JS fxn and a commandLink with the appropriate action which would be called by the clickLink fxn. the clickLink fxn would in turn be called on the onClick of the command button.

This idea being taken form this page:
Using Javascript with JSF

Now the problem is that in this example we're using the Tomahawk JSF commandlink.

<t:commandLink id="hiddenLink" forceId="true" action="register" >
<hutputText value="tester" />
</t:commandLink>

But if I use the <h:commandLink from the ibm implementation that our architect insists on, it doesnt have the "forceId" property. Without that property being there, The button does get disabled but the form doesnt get submitted.

1. Is this is the most optimal approach to achieve what I want (Disable cmd button after one click, yet submit form)
2. Is it possible to use the regular implementation of commandLink instead of the Tomahawk one and still achieve the same objective?
 
Krithika Srinath
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the standard to achieve this.

As you have done have a commandButton as:



Then create a hidden comand link that calls an action on your backing bean that processes the form:



Then add script to disable the submit button and click on the link.



Hope this helps.
 
Aj Bujanany
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks a lot!!! It helped me a lot.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!