How to display a p:graphicImage after clicking an h:commandButton [duplicate] - jsf

This question already has answers here:
Show progress image while executing JSF managed bean action
(1 answer)
JSP processing message
(1 answer)
Closed 3 years ago.
I am having a run button with action as an execution called from mybean. Once button executed running gif should display.
Which action should trigger the running.gif to be displayed?
Here is my code
<h:commandButton value="Run" action="#{mybean.execute()}" class="btn btn-success btnWidth" style="margin-left:15px;margin-right:15px;"/>
<p:graphicImage url="/resources/icons/running.gif" height="20" width="20" />

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%" />

How can I reset PrimeFaces tabs [duplicate]

This question already has answers here:
Reset input fields in primefaces
(5 answers)
Clear JSF form input values after submitting
(5 answers)
Closed 6 years ago.
I have A PrimeFaces wizard each tab contains InputText fields or SelectOneMenu menus ... how could I reset all fields and menus in all tabs on submit button ??
I'm using primefaces 5.3
thank you
PrimeFaces has a component for clientside resets
<p:commandButton value="Reset Tag" update="#form" process="#form" style="margin-right:20px;" >
<p:resetInput target="***idFromYourTag***" />
</p:commandButton>
If you need reset the backing bean values, you need to write a method.
See also ResetInput

Hide/Show component with backing bean [duplicate]

This question already has an answer here:
Ajax update/render does not work on a component which has rendered attribute
(1 answer)
Closed 6 years ago.
I having a list of items to display, where I wanted to restrict user from clicking the ShowMore button when the set of items have all displayed.
my code:
<div class="row center">
<h:commandButton id="morebutton" rendered="#{homeBean.hasMoreProjects()}" styleClass="hoverable btn-large yellow lighten-2 black-text" value="SHOW MORE" >
<f:ajax listener="#{homeBean.showMore()}" render="result morebutton" />
</h:commandButton>
</div>
The issue here is the button will not be hide whenever the list of items is all shown, but it will be hide when I refresh the whole page.
How can I check the method when I check the button?
Any helps will be much appreciate, Thanks
EDIT 1:
this question is slightly different from the question Ajax update/render does not work on a component which has rendered attribute, this question stating the commandLink button targeting to the button itself for hide/show rendering where the issue from the link is to target the input form
You always need to render the parent component in jsf2, this should work:
<a4j:outputPanel id="morebuttonPanel" styleClass="row center">
<h:commandButton id="morebutton" rendered="#{homeBean.hasMoreProjects()}" styleClass="hoverable btn-large yellow lighten-2 black-text" value="SHOW MORE" >
<f:ajax listener="#{homeBean.showMore()}" render="result morebuttonPanel" />
</h:commandButton>
</a4j:outputPanel>

Primefaces commandLink works but not commandButton [duplicate]

This question already has answers here:
Differences between action and actionListener
(4 answers)
Closed 6 years ago.
I have identical actions for commandLink and commandButton. However, commandLink works as expected. But with commandButton no action occurs. Am I missing syntax?
<p:commandLink value="Submit" action="#{beanController.getStr(strSearch)}" ajax="false"/>
<p:commandButton value="Submit" actionListener="#{beanController.getStr(strSearch)}" ajax="false"/>
If you intend for navigation to occur you should use action not actionListener in your commandButton, so:
<p:commandButton value="Submit" action="#{beanController.getStr(strSearch)}" ajax="false"/>
commandButton button generates a HTML <input type="submit"> element and the commandLink generates a HTML <a> and comandButton is using to submit the form whereas commandlink is used to submit a link,so your form is not submitting i'll suggest you to check if there is any nested form is present or not or if there is multiple forms in your code or any other issue which is causing in form submit, if you can then post your code.

p:dialog closed regardless to condition in oncomplete [duplicate]

This question already has answers here:
Keep p:dialog open when a validation error occurs after submit
(6 answers)
Closed 3 years ago.
I use JSF 2.0 and Primefaces 3.5
I have a dialog and in case if data not passed my validation rules not closed dialog
<p:commandButton id="seasonSave" actionListener="#{adminSeasonController.add()}"
action="#{adminManageTournamentController.generateTournamentNames()}"
value="#{msg.save}" ajax="true"
onmousedown="return validateSubmit('createSeasonForm', ['name_season'], 'lang')"
oncomplete="if (#{not adminSeasonController.validationFailed}) addSeasonDialog.hide()"
update=":manageTournament:name_season, :manageTournament:title ,:menuForm:growl, #form">
I see in controller validationField = true, but dialog closed.
how I can resolve my problem?
You can look primefaces showcase for this problem.
http://www.primefaces.org/showcase/ui/dialogLogin.jsf
Update of the link: https://www.primefaces.org/showcase/ui/overlay/dialog/loginDemo.xhtml
<p:commandButton id="seasonSave" actionListener="#{adminSeasonController.add()}"
action="#{adminManageTournamentController.generateTournamentNames()}"
value="#{msg.save}" ajax="true"
onmousedown="return validateSubmit('createSeasonForm', ['name_season'], 'lang')"
oncomplete="if (!args.validationFailed) addSeasonDialog.hide()"
update=":manageTournament:name_season, :manageTournament:title ,:menuForm:growl, #form"/>

Resources