Why no action is firing after uplading a file with jsf [duplicate] - jsf

This question already has answers here:
commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated
(12 answers)
How to use PrimeFaces p:fileUpload? Listener method is never invoked or UploadedFile is null / throws an error / not usable
(11 answers)
Closed 3 months ago.
I am uploading csv file that have only one entry in it and after uploading when try to delete by selecting that entry delete is not firing for first time from second time it if firing working fine.
For that I am using p:fileUpload jsf tag and in bean am uploading file.
JSF code :
<h:outputText value="Upload Numbers CSV file" style="font-weight:bold;font-size:9pt" />
<p:messages id="fileuploadmsg" autoUpdate="true"/>
<p:fileUpload fileUploadListener="#{ABean.uploadNumbers}"
allowTypes="/(\.|\/)(csv)$/" update="fileuploadmsg">
</p:fileUpload>
Java Method for upload :
public String uploadNumbers(FileUploadEvent event) {
//Upload part here After upload reloading page.
RequestContext.getCurrentInstance().execute("window.location.reload()");
}
** Note: I am getting this issue only when first and uploading only one entry**

Related

Insert Image primefaces on form with link [duplicate]

This question already has answers here:
How to use PrimeFaces p:fileUpload? Listener method is never invoked or UploadedFile is null / throws an error / not usable
(11 answers)
How to upload file using JSF 2.2 <h:inputFile>? Where is the saved File?
(1 answer)
Load images from outside of webapps / webcontext / deploy folder using <h:graphicImage> or <img> tag
(4 answers)
Closed 3 years ago.
I have a entity attribute String for input a link_logo in my form , i want just to know what can i write on the view for input the logo.
The Attribute on entity (agency):
#Column(name = "Logo")
private String link_logo;
My save method it worked and the bean too. I searched in the showcase but no result.
there is my view code now :
<div class="ui-sm-12 ui-md-2 ui-lg-1">
<p:outputLabel value="Upload image:" for="img" />
</div>
<div class="ui-sm-12 ui-md-4 ui-lg-5" >
<p:graphicImage id="img" value="#{agenceFormBean.agence.link_logo}" style="width:100%" />
</div>
any solutions please ?
You can use this the show image with url
<p:graphicImage id="img" value="#{yourView.link_logo}" style="width:100%" />

JSF outputlabel click event [duplicate]

This question already has an answer here:
How to call JSF backing bean method only when onclick/oncomplete/on... event occurs and not on page load
(1 answer)
Closed 5 years ago.
first of all, I am very new to JSF and web development.
What I want to do is to print a message in the console if the user click an outputlabel.
{businessBean.select()} gets called only on page refresh and not when I click.
<h:outputLabel styleClass="cat" id ="businesstasks" onclick="setColor('businesstasks'); #{businessBean.select()}">
Business and productivity
</h:outputLabel>
My test bean:
#ManagedBean(name="businessBean")
#SessionScoped
public class businessBean {
public void select(){
System.out.print("Test");
}
}
I get "Test" only when I refresh the page but I want to get it on every click.
Thanks for helping!
Is there a reason you 'need' the outputLabel to execute an action? Because onclick will execute it as a javascript, and that interaction can cause issues if you're calling the bean action method. You could use <h:commandLink action="#{businessBean.select}" /> within your output label.

commandLink does not call action method with correct backingBean [duplicate]

This question already has answers here:
commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated
(12 answers)
Closed 5 years ago.
I am working with JSF trying to do a .xhtml as simple as :
<ui:composition ...>
<span class="fr">
<a4j:commandLink value="#{msg.label_return}"
action="#{backingBeanRef['navigateBack']()}"
rendered="#{backingBeanRef['returnValueStackBean']['returnValueStack']['size']() ne 0}"
render="#{render}"/>
</span>
</ui:composition>
so I can include it in several views. It works as expected in most of them but one, in which the action method is never called.
I have tried to call the method without parameterization (#{myBean.navigateBack()}) and it still doesn't works.
I have also tried to write #{backingBeanRef'navigateBack'} above the commandLink and the method is called so the backingBeanRef is correct and everything should work but it doesn't.
At this point I have no clue about what is happening, does anyone knows?
Thanks in advance
I had two <h:form> in my code. Once I removed one of these, this got fixed.

Call same bean method from multiple onclick with different parameters not working [duplicate]

This question already has an answer here:
Multiple action listeners with a single command component in JSF
(1 answer)
Closed 6 years ago.
I'm using Primefaces and jsf in my application. I'm using mutiple commandlink with onclick function. All the onclick function call the same bean method but parameters are different. Pages are working fine & passing parameters also different even though all the pages are showing same metrics.
Based on parameter should display different metrics but not working properly.
XHTML:
<h:commandLink value="Defects"
action="#{loginbean.setCurrPage('metrics','defects.xhtml')}"
onclick="#{reportsBean.MetricPage('defect')}"
rendered="#{sub_selected =='defects'}" />
<h:commandLink value="Test Case"
action="#{loginbean.setCurrPage('metrics','testcase.xhtml')}"
onclick="#{reportsBean.MetricPage('testcase')}"
rendered="#{sub_selected =='testcases'}" />
Bean:
public void MetricPage(String ipageid) {
metricssection = metricsProcess.getMetricsProcess().getUserMetrics(ipageid, SessionMgr.getProj());
metricsfeature = metricsProcess.getMetricsProcess().getMetricFeatures(ipageid, SessionMgr.getPro());
}
How can i resove the problem?
onclick is a client side event. You can only call Javascript functions from onlcick. Not methods from Managedbean.
Since you tagged this question as Primefaces, I assume you are using Primefaces. In that case you can use p:remoteCommand
See this on how to use p:remotecommand

primefaces commandbutton update does not work [duplicate]

This question already has answers here:
commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated
(12 answers)
Closed 2 years ago.
I have minimized my code to better show you what is not working.
<h:body>
<f:view>
<h:form id="wbSelectForm">
<p:commandButton id="viewWorkbenchButton" icon="ui-icon-show"
title="View Workbench" update=":wbTestPanel"
actionListener="#{WorkbenchControllerBean.test}">
</p:commandButton>
</h:form>
<p:panel id="wbTestPanel">
Test: Active Wb: #{WorkbenchControllerBean.number}
</p:panel>
</f:view>
</h:body>
When i press the commandButton, i would expect that 'wbTestPanel' is being updated, which does somehow NOT happen. I know that because WorkbenchControllerBean.getNumber() is not called.
I am using primefaces 3.5. I already tried differend values for 'process'-attribute as well as putting RequestContext.getCurrentInstance().update("wbTestPanel")in WorkbenchControllerBean.test()-method.
I think that maybe the code is right, but there are any settings in the project or runtime environment (Java 7 + JBoss 7.1.1) that prevent primefaces from updating the other panel. Could you please give me a hint what to search for?
Thanks in advance!
Are you sure that test() method is invoked?
If yes, can you try with following update expression?
update="#([id$=wbTestPanel])"
Otherwise, it maybe the case that test() method is not called because of a validation error. If that is the case, you can inspect it with debug or firebug.
Use : before id
Remember
If you make a dialog.
Before Dialog old form tag should be closed.
Then dialouge content should be placed into another form.
Use update=":dialougeid, :dialougeFormId"

Resources