f:ajax not working on tomcat7/eclipse - ajax

I have this very simple code which works fine until I add a f:ajax tag.
Code that works:
<h:commandButton disabled="#{!feature.available}" class="featureButton"
value="#{feature.selected ? 'selected': feature.available? 'available':'unavailable'} "
style="vertical-align: top;" action="#{Bean.toggleFeature(feature)}">
</h:commandButton>
Code that doesn't work:
<h:commandButton disabled="#{!feature.available}" class="featureButton"
value="#{feature.selected ? 'selected': feature.available? 'available':'unavailable'} "
style="vertical-align: top;" action="#{Bean.toggleFeature(feature)}">
<f:ajax event="click" />
</h:commandButton>
As far as I can tell the jsf.js file is loaded fine, this is automatically added by the facelet servlet to the head of my rendered document
<script type="text/javascript" src="/www/javax.faces.resource/jsf.js.xhtml?ln=javax.faces"></script> and I was even able to do a jsf.ajax.request directly from javascript and got the page to rerender something.
I am using mojarra 2.1.13, tomcat 7, eclipse juno, java 7.
Any thoughts on what I might be doing wrong or how I might be able to troubleshoot this issue? debugging it in javascript didn't help at all.
Thanks.

I failed to mention above that I had nested ui:repeats and it turns out there is a bug with mojarra regarding that. As far as I can tell the fix has just been committed but it isn't out as a jar yet however I tried myfaces and it worked fine, so I'll do that for now. Here are the bug details:
http://java.net/jira/browse/JAVASERVERFACES-1817

Related

Updating p:dialog clears p:message which inside same dialog

Am Upgrading application from PrimeFaces 6.1 to PrimeFaces 6.2. I have <p:dialog appendTo="#(body)" id="dialog" widgetVar="widgetVar" modal="true"> with <p:message id="validation"> element inside it.
Am opening dialog using PF('widgetVar').show(). When I click p:commandButton inside dialog, doing some validation and showing message using below code,
FacesContext.getCurrentInstance().addMessage("validation", new
FacesMessage(FacesMessage.SEVERITY_ERROR, "validation error", null))
With in the same method am reopening dialog and update it with below code,
RequestContext context = RequestContext.getCurrentInstance();
context.update("dialog");
context.execute("PF('widgetVar').show();")
In PrimeFaces 6.1 its working fine and validation message getting displayed. But in PrimeFaces 6.2 validation Message not displaying in dialog. I know RequestContext is deprecated in PF 6.2. Am also tried with below code,
PrimeFaces primefaces = PrimeFaces.current();
primefaces.ajax().update("dialog");
primefaces.executeScript("PF('widgetVar').show();");
Facing same issue. I saw that message displaying and immediately its getting cleared.
But, when I remove the ajax update primefaces.ajax().update("dialog"); It's working fine.
What is the reason for this issue?

p:fileDownload not working from modal dialog (due to ajax="false")

I need to use PrimeFaces p:fileDownload from within a data-table inside a modal dialog, but due to the use of ajax="false" (else the file download won't be triggered) inside command button the dialog disappears. Do you have any clue?
<p:commandLink value="#{row.name}" ajax="false"
actionListener="#{documentsBean.fileDownloadController(row)}">
<p:fileDownload value="#{documentsBean.fileStream}" />
</p:commandLink>
Above is the command link triggering the file download and it is included inside a data-table, the data-table itself is inserted in a modal dialog. Any help appreciated.
I Tested this method and it's worked fine for me, but to make a complete answer add some code to understand if there is a problem
public void downloaddoc(FileUploadEvent file) throws FileNotFoundException, TransformerConfigurationException, TransformerException {
InputStream input = file.getFile().getInputstream();
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
setDownload(new DefaultStreamedContent(input, externalContext.getMimeType(file.getFile().getName(), file.getFile().getName()));
}
you can read more in Primefaces Web Site
Hope that helped you.

Primefaces 5.1: #this ajax update not working anymore

I'm having a little application with a selectOneMenu which needs to update the selected value in the backing bean. Easy thing. I used Primefaces 4 and the code looks like this:
<p:selectOneMenu id="customersMenu"
value="#{customerController.selectedCustomer}" style="float:right"
converter="#{customerConverter}">
<p:ajax event="change" update="#this, :tabview" />
<f:selectItem itemLabel=" Kunde auswählen" itemValue="" />
<f:selectItems value="#{customerController.customers}"
var="customer" itemLabel="#{customer.name}" itemValue="#{customer}" />
</p:selectOneMenu>
With the ajax update on change the backing bean is updated correctly and a tabview is updated correctly too.
Now I replaced the primefaces4.jar with the primefaces5.jar and this is not working anymore. When checking with FireBug in Bugzilla I can see a ominous error saying: 'TypeError: PrimeFaces.Expressions is undefined'. Anyone got that too?
I played with the settings and found that the '#this' in ajax update seems to cause the error. I checked the migration guide, should be working - shouldn't it?
Anyway, I suceeded with removing '#this' and adding a ' onchange="submit();"' to my selectonemenu. The bean is now updated. I don't understand why, can anyone tell me?

Why a View is reinstancied, when we click a commandButton displayed in richfaces component displayed after an ajax call?

Initially my question was : Does richfaces 4.3.4 support JSF 2.2 and ViewScoped?
But now the question is in the title.Thanks :)
I'm trying to solve this problem. Why a View is reinstancied, when you click a command button displayed in richfaces component displayed after an ajax call ?
It seems i'm not alone : [anotherLink], anotherlink 2.
Resolve thanks to this.
Thanks BalusC.
EDIT : But it's no more working when you try to add an rich:fileupload neither with h:inputFile... It will displayed strange html code in a newly textarea ....It's weird...
<rich:fileUpload id="upload" fileUploadListener="#{analyse.test}" acceptedTypes="bam,pdf,png" ontyperejected="alert('Seulement les fichiers avec l'extension bam et pdf sont acceptés.');" maxFilesQuantity="3">
                 <a4j:ajax event="uploadcomplete" execute="#none" render="upload" />
</rich:fileUpload>

Testing a method that implements IHttpHandler.ProcessRequest

So I have a method that implements IHttpHandler.ProcessRequest. It accepts an HttpContext parameter. This parameter is just a form that is filled out with some XML. Here is the HTML that I am using to generate the post context:
<html>
<body>
<form name="form1" method="post" action="http://localhost:7703/api.ashx">
<textarea name="XML" id="XML" rows="25" cols="100"></textarea>
<br/>
<input type="submit" value="submit"/>
</form>
</body>
</html>
As you can see, very simple. This is just used for testing purposes. What I am doing is posting XML in that textbox, and hitting submit. However, I am not sure what to attach my visual studio project to in order to debug. I try attaching it to w3wp.exe like I do when I test the app in a browser and stuff, but that doesn't seem to be working. It still says "This breakpoint will never be hit, no symbols loaded..." blah blah blah, when I put a breakpoint next to the ProcessRequest method and attach.
How do I test this properly?
Thanks guys.
If you run this locally you should be able to "run" it from within Visual Studio and VS will automatically attach it self to the correct process.
If I attach to the development server at the same port as the post, it works! :)

Resources