in my JSF 2.2 application I was trying to create an AJAX request using RichFaces 4.3.2 with .
The rendered HTML is:
<a href="#" id="x" name="x" onclick="RichFaces.ajax(x;,event,{x:x} );return false;">
The problem is that after clicking the link, nothing happens and an error in my Chrome Console appears:
Uncaught TypeError: Object #<Object> has no method 'ajax'
When I type RichFaces into console I get some autocomplete possibilities like `Event, valueOf' etc. but it doesn't see any specific RichFaces functions.
It looks like the RichFaces library wouldn't be attached at all but I have no idea why.
Why is it happening?
The code of the commandLink:
<ui:repeat value="#{commonsOperations.newsList}" var="n">
<li>
<a4j:commandLink action="#{commonsOperations.setSelectedNews(n)}"
value="#{n.title}" render="content" />
</li>
</ui:repeat>
I found out the problem why RichFaces libraries were not loaded properly was the conflict between RichFaces and PrimeFaces. After removing PrimeFaces from POM, all RichFaces javascript files are loaded.
Related
Primefaces 7.0, JSF 2.1.19
I am trying to replace richfaces 3.3.3 with primefaces 7.0 (and upgrade JSF to 2.1) and got a special behaviour from the fileUpload widget: When I first render the page it works without problems (no fileupload done, just render it), then I navigate again to the same page it is broken:
The fileupload component:
<p:fileUpload disabled="#{antragAttachments.fileUploadDisabled}" id="attachmentUpload" widgetVar="attachmentUpload" binding="#{antragAttachments.fileUpload}"
fileUploadListener="#{antragAttachments.fileUploadListener}" label="Durchsuchen..." uploadLabel="Datei anhängen" cancelLabel="Abbrechen" invalidFileMessage="test typ"
mode="advanced" fileLimit="1" sizeLimit="15728640" invalidSizeMessage="Der Dateianhang ist zu groß! Die maximale Größe beträgt 15MB!" previewWidth="1"
oncomplete="uploadComplete();" auto="true">
</p:fileUpload>
This is the (menu) component the navigate again to the xthtml:
<ui:repeat value="#{name}" var="item" >
<div id="menuOP" class="ebene#{item.shifting} #{item.selected ? 'divselected' : 'divnotselected'} #{item.spriteClass}">
<p:commandLink immediate="#{item.immediate}" value="#{item.label}" rendered="#{item.enabled}" action="#{item.navigate}"
styleClass="#{item.selected ? 'selected' : 'notselected'}" oncomplete="#{item.oncomplete}"/>
<h:outputText id="menuNoLinkText" rendered="#{!item.enabled}" styleClass="disabled" value="#{item.label}" />
</div>
</ui:repeat>
I tried to remove the immediate, set the type to "submit", use h:commandLink (without the oncomplete of course) just to see if I can get this running somehow. Does not work.
I also looked at the Primefaces fileupload introduction from balusC, but my problem is not the fileupload, it is the second rendering. There is also a Primefaces forum entry about something similar, but the trick von melloware did not work also.
What I do not understand, by the first click on the menu the rendering works fine and after every click on the menu-commandlink the browser console tells me that the widget is not available.
I found examples with similar problems, but there is most of the time a javascript call of the widget like PF('attachmentUpload').doSomething(), but this is not the case here.
EDIT:
I found out that when I first click on the commandlink the fileupload.js is loaded:
By the second click this is not the case anymore:
I also found a thread with the same problem: <p:layout> and <p:fileUpload> not working on page refresh, but there the only solution seems to be to take the css and js for fileupload and add it manualy to as resource... which is a little creepy...
I am using JSF 1.2 and Richfaces 3.3.3 , I've tried
<a4j:region>
<t:selectOneMenu id="comp1" value="#{bB.selectedTeam}" style="width: 200px">
<t:selectItems value="#{bB.teams}" var="team" itemLabel="#{team.desc}" itemValue="#{team.code}"/>
<a4j:support event="onchange" reRender="comp2"/>
</t:selectOneMenu>
but didn't work.
comp1 is a Dojo combobox component and it doesn't do anything when onchange event happens.
JSF doesn't keep track of plain HTML. If you want to be able to rerender something it has to be wrapped in a component, like <a4j:outputPanel> and then you have to rerender that component.
it turned out the html object rendered by <t:selectItems> was transformed to a dijit component when page loads, that conversion to dojo in javascript side does that the user won't interact with the object we indicated to do ajax call in the event onchange through
<a4j:support event="onchange" reRender="comp2"/>
so the solution was to use in order to attach the event to the dojo component in javascript browser side.
I am using JSF 2.0 tag <h:commandLink> and I'm trying to open an window with target as _blank. In the target I am trying to populate the document which was fetched from the server. But while doing so I am getting an error in jsf.js (function name is jsfcljs) at f.submit().
Declaration is as follows:
<h:commandLink id="viewDocument" value="#{template.orderBean.documentBean.documentName}"
action="#{template.viewCustomDocument}" target="_blank" styleClass="textbold">
<f:param name="documentId" value="#{template.orderBean.documentBean.documentId}"/>
</h:commandLink>
The error I got is
Object doesn't support this property.
If I use <h:commandButton> instead then I am able to call the server and fetch the document.
What can the problem cause be?
Edit - please see bottom.
I've got a primefaces calendar component on my page. The textbox appears but when I click it the calendar does not appear. Here is the component code.
<p:calendar id="clientApptTime" value="#{ScheduleMB.datePrime}"
pattern="HH:mm" timeOnly="true" />
My facelet and the template both use h:head and h:body tags and I have the
xmlns:p="http://primefaces.org/ui" up top.
I'm using primefaces 3.3.1, java 1.6 and Mojarra 2.1.
Also I'm not getting any error messages on either the server or my error console.
Anybody have any ideas?
And here is the rendered page source:
span id="j_idt34:clientApptTime"><input id="j_idt34:clientApptTime_input"
name="j_idt34:clientApptTime_input" type="text" class="ui-inputfield ui-widget
ui-state-default ui-corner-all" /></span><script id="j_idt34:clientApptTime_s"
type="text/javascript">$(function()
{PrimeFaces.cw('Calendar','widget_j_idt34_clientApptTime',
{id:'j_idt34:clientApptTime',popup:true,locale:'en_US',dateFormat:'m/d/y
hh:mm',timeOnly:true,stepHour:1,stepMinute:1,stepSecond:1,hourMin:0,hourMax:23,minuteMin:0,
minuteMax:59,secondMin:0,secondMax:59});});</script>
Answer seems to be that Primefaces will not work with Tomahawk. After I removed all the Tomahawk references Primefaces worked fine. Anyone know what I can do about that (this may be a question for another post)?
wonder if you can help me. For some reason, I am getting javascript errors for my richface components, and this has seemed to have happened without any changes to the code that was working correctly just a few days ago.
Anyway, as an example I am using a rich:componentControl as follows:
<a4j:commandButton onclick="#{rich:component('headerpopup')}.show()" id="addheader" styleClass="saveState" value="Add Column Header">
<rich:componentControl for="headerpopup" attachTo="addheader" operation="show" event="onclick"/>
</a4j:commandButton>
And the javascript error I get is:
Uncaught TypeError: Cannot call method 'show' of undefined
I'm suspecting I am missing a javascript file that Richfaces should be providing, is this correct?
I'm using Richfaces 3.3.1 on Jboss 5.1.0 and Seam 2.2.2.
Any help would be helpful.
oops....
It was a schoolboy error:
I had removed the jQuery noConflict line, not knowing what it was...
<script>var $e = esiQuery.noConflict();</script>