-
1. Re: Error with a4j:form and h:commandLink
sergeysmirnov Dec 12, 2007 9:16 PM (in response to terryb)try to use a4j:htmlCommandLink
Info: http://livedemo.exadel.com/richfaces-demo/richfaces/htmlCommandLink.jsf?c=htmlCommandLink -
2. Re: Error with a4j:form and h:commandLink
terryb Dec 12, 2007 9:28 PM (in response to terryb)I tried a4j_commandLink. it doesn't produce error buy it does not open the window. it seems to ignore target="_blank" ?
my application requires to open new window. -
3. Re: Error with a4j:form and h:commandLink
sergeysmirnov Dec 12, 2007 9:46 PM (in response to terryb)Did I say a4j:commandLink ?
-
4. Re: Error with a4j:form and h:commandLink
terryb Dec 13, 2007 2:30 AM (in response to terryb)Sergey, perhaps I am still doing something wrong because I am getting same error even with a4j:htmlCommandLink.
... <a4j:form id="paymentReminderLetter" styleClass="edit" ajaxSubmit="true" reRender="paymentReminderSearchResult" onsubmit="return validateForm(document.paymentReminderLetter);"> ... <a4j:htmlCommandLink value="Generate Letter" action="#{paymentReminderLetter.generateLetter}" target="_blank" type="submit"/> ...
It works ok, if I remove target="_blank" from a4j:htmlCommandLink. -
5. Re: Error with a4j:form and h:commandLink
sergeysmirnov Dec 13, 2007 3:05 PM (in response to terryb)Why you need ajaxSubmit="true" on the a4j:form ?
-
6. Re: Error with a4j:form and h:commandLink
terryb Dec 13, 2007 9:22 PM (in response to terryb)Thanks, removing it fixed the the JavaScript error. my first ever use of commandLink, and being new to this stuff it is sometimes mix and match to see what works. appreciate your patience.
I'm pretty close now on this one; just one final issue now (I hope):
I now have two a4j:commandLink and one a4j:htmlCommandLink on this page. a4j:htmlCommandLink has 'target="_blank'. If I click a4j:htmlCommandLink, a new window is opened with pdf as expected. But clicking any of the a4j:commandLink right after that, has unusual behaviour: It runs the action action associated with a4j:commandLink but it then also runs action associated with a4j:htmlCommandLink - as if I had clicked that one too.
I guess it is combination of different types making it harder.XHTML: <a4j:form id="paymentReminderLetter" styleClass="edit" onsubmit="return validateForm(document.paymentReminderLetter);"> <rich:separator height="1"/> <div class="dialogtable"> <a4j:outputPanel id="formPanel"> <h:panelGrid columns="3" rowClasses="prop" columnClasses="name,value,hint"> ... ... </h:panelGrid> </a4j:outputPanel> </div> <rich:separator height="1"/> <div> <table > <tr class="prop"> <td class="value"> <div class="tableControl"> <a4j:htmlCommandLink id="checkAvailable" value="Check Available" action="#{paymentReminderLetter.submitSearchAction}" type="submit" reRender="paymentReminderSearchResult"/> <a4j:htmlCommandLink id="reset" value="Reset" action="#{paymentReminderLetter.reset}" type="submit" reRender="paymentReminderSearchResult,formPanel" /> <a4j:htmlCommandLink value="Generate Letter" action="#{paymentReminderLetter.generateLetter}" onclick="return generateLetter(document.paymentReminderLetter);" *also having this onclick in does not submit the form.* reRender="paymentReminderSearchResult" *also reRender does not work on this.* target="_blank" type="submit" /> </div> </td> </tr> </table> </div> </a4j:form> </td></tr> </table> <rich:spacer height="5"/> <div class="results"> <a4j:outputPanel id="paymentReminderSearchResult"> ... </a4j:outputPanel <script type="text/javascript"> //<![CDATA[ function generateLetter(form) { if (!confirm('Generate letters for applications in range\nand flag them as reminded?')) { return false; } return validateForm(form); } function validateForm(form) { if (!validateDate(form.elements('paymentReminderLetter:declaredDateFromInputDate'), "Enter valid value for 'Declared date from'.")) { return false; } if (!validateDate(form.elements('paymentReminderLetter:declaredDateToInputDate'), "Enter valid value for 'Declared date to'.")) { return false; } return true; } focusOn(document.paymentReminderLetter.elements('paymentReminderLetter:declaredDateFromInputDate')); //]]> </script> </ui:define> </ui:composition> paymentReminderLetter: @Name("paymentReminderLetter") @Scope(ScopeType.CONVERSATION) public class PaymentReminderLetter { ... public String reset() throws ApplicationException { this.declaredDateFrom = null; this.declaredDateTo = null; this.docFormat = Constant.Itext.DOC_TYPE_PDF; this.maxLetterPerAttempt = this.MAX_LETTERS_TO_PRINT_DEFAULT; this.maxQueryResults = Constant.Database.MAX_QUERY_RESULT; this.regenerate = false; pageAction(); submitSearchAction(); return null; } public String submitSearchAction() throws ApplicationException { this.maxQueryResults = Constant.Database.MAX_QUERY_RESULT; submitSearch(); return ""; } public String generateLetter() throws ApplicationException { this.maxQueryResults = this.maxLetterPerAttempt; submitSearch(); if (this.getResultCount() <= 0) { FacesMessages.instance().add(FacesMessage.SEVERITY_INFO, "No declard but unpaid applicants exist within specified criteria."); } else { flagAsReminded(); } return null; } private void submitSearch() throws ApplicationException { try { Query query = em.createQuery(this.getEjbql()); query.setMaxResults(this.maxQueryResults); paymentReminderLetterList = query.getResultList(); this.executeSearch = true; } catch (Exception e) { throw new OnlineException(OnlineException.ERROR_EXTRACTING_RECORD, "Payment Reminder Letter. Error: " + e.getMessage()); } } }
-
7. Re: Error with a4j:form and h:commandLink
sergeysmirnov Dec 13, 2007 9:46 PM (in response to terryb)a4j:htmlCommandLink is NOT an Ajax link. So, reRender attribute does not make sense on it.
a4j:htmlCommandLink is a regular link. So, when you click it, the whole page is reloaded unless you use target attribute.