Primefaces new line in confirm message - primefaces

Helllo, I have a problem and here I do not find function solution.
I have .properties file confirmClone=Bla bla bla
and this code
<p:confirm header="Confirm" message="#{msg.confirmClone} #{msg.confirmNextText}" icon="ui-icon-alert" />
I use primefaces 6.1.
What I nedd to add, if I want empty line between msg.confirmClone and msg.confirmNextText ?

This will work.
<p:confirm header="Confirm"
escape="false"
message="#{msg.confirmClone} <br/> #{msg.confirmNextText}"
icon="ui-icon-alert" />

Related

How clean data in <p:overlayPanel ... when is opening or cloasing

<p:overlayPanel appendToBody="true"
id="panel_l#{level.name.hashCode()}
f{filterTypeConfiguration.filterType.name.hashCode()}"
for="conrolForm_l#{level.name.hashCode()}f
#{filterTypeConfiguration.filterType.name.hashCode()}:
button_l#{level.name.hashCode()}f
#{filterTypeConfiguration.filterType.name.hashCode()}"
dynamic="true" >
...
and in overlayPanel I have:
<p:inputText value="#{filterTypeConfiguration.textToSearch}">
<p:ajax id="ajaxFilterSearch" event="keyup" update="overlayForm_l
#{level.name.hashCode()} f#{filterTypeConfiguration.filterType.name.hashCode()}
:select_l#{level.name.hashCode()}
f#{filterTypeConfiguration.filterType.name.hashCode()}"
</p:inputText>
I need clean data in inputText when overlayPanel is opening or closing.
I didn't use p:overlayPanel yet but I am able to trigger p:dialog diaglodReturn event like, I think it should be similar like this
<p:ajax event="dialogReturn" update="#form" listener="#{backing.refreshPage}" />
Or
Example from primefaces showcase, How about add action attribute for button?
<p:commandButton id="imageBtn" value="Basic" type="button" action="#{backing.refresh}" />
<p:overlayPanel id="imagePanel" for="imageBtn" hideEffect="fade">
<p:graphicImage name="/demo/images/nature/nature1.jpg" width="300" />
</p:overlayPanel>

How to stop PrimeFaces p:commantLink from reloading the page

I've got a PrimeFaces commandLink which should just make some area visible. However i can not stop it refeshing the page each time it is clicked. I've read some topics about it already but it just does not help.
<script type="text/javascript">
function show() {
$("div[id*='models']").show();
}
</script>
...
<p:commandLink global="false"
onclick="show(); return null;">
<h:outputText value="show..." />
<f:ajax execute="#form" render="#none" />
</p:commandLink>
<p:panel id="models" style="display:none"> Some content</p:panel>
Does anymone have an idea, please?
add and update attribute and list the components you want to update,
<p:commandLink global="false" update="models"
onclick="show(); return null;">
<h:outputText value="show..." />
<f:ajax execute="#form" render="#none" />
</p:commandLink>
you have examples at showcase http://www.primefaces.org/showcase/ui/button/commandLink.xhtml;jsessionid=h74zksrbt9hia24tk9nah5st
I've just found the Solution myself.
There was primefaces javascript error that I did not see
TypeError: this.visibleStateHolder is undefined
After adding closable="true" to panel it works just fine!

p:calendar value not updated with dateSelect

I have got a p:calendar component inside a p:dialog one. When dialog is shown it takes its value from property in back bean, but when a new date is selected, the SelectEvent arrived to the listener brings the old value and not the new selected date. What is wrong on next code?
<p:dialog id="eventDialog" widgetVar="eventDialog" header="#{textos.confirmarFechaHora}" showEffect="clip"
hideEffect="clip" modal="true"
appendToBody="true"> <!-- A false, no entran los eventos tras modificar la fecha/hora del calendario -->
<h:panelGrid id="eventDetails" columns="2">
<h:outputLabel for="calHora" value="#{textos.horaComienzo}" />
<p:calendar id="calHora" locale="es" pattern="dd/MM/yyyy HH:mm"
value="#{schedulePFController.fechaComienzo}" mode="inline"
required="true"
accesskey="true" valueChangeListener="#{schedulePFController.cambiaHoraComienzoVCL}">
<p:ajax event="dateSelect" listener="#{schedulePFController.cambiaHoraComienzo}"/>
</p:calendar>
<p:commandButton value="#{textos.cancelar}" oncomplete="eventDialog.hide();"/>
<p:commandButton value="#{textos.mostrarCitas}"
action="#{schedulePFController.verEntradaCalendario}"
rendered="#{schedulePFController.clickedOnCita}"/>
<p:commandButton value="#{textos.addCita}"
action="#{schedulePFController.addCita}"
rendered="#{!schedulePFController.clickedOnCita}"/>
</h:panelGrid>
public void cambiaHoraComienzo(SelectEvent ev) {
Date date = (Date)ev.getObject();
fechaComienzo = date;
horaComienzo = new DateCita(date);
logger.debug("Cambiando fechaComienzo "+horaComienzo.toString()+" +++++++++++++++++++++++++++++++++++++++++");}
I dont know why you are using valueChangeListener="#{schedulePFController.cambiaHoraComienzoVCL}" in p:calender when you are already invoking a listner in your ajax call.
Just remove valueChangeListener="#{schedulePFController.cambiaHoraComienzoVCL}" from your p:calender and then check.listener listener="#{schedulePFController.cambiaHoraComienzo}" that you are using in p:ajax tag is enough
You are doing this the wrong way, to complicated.
Take a look here:
<p:calendar value="#{ivkDaten.beginn}" locale="de" lang="de"
pattern="dd.MM.yyyy" label="#{messages['services.ivk.beginn']}:"
width="80" id="ivkbeginn" effect="fadeIn" readonlyInput="true" disabled="true"
showOn="button" mindate="#{services.minDate}" maxdate="#{services.maxDate}">
<p:ajax event="dateSelect" listener="#{ivkDaten.recalcDate()}"
update="ablauf" />
</p:calendar>
You need to set getter/setter for beginn and when you call the method "reclacDate()" you can use beginn and i'm pretty sure you will have the new date.
This seems to be a problem with older versions of PrimeFaces. This has been fixed in PrimeFaces 3.3 or 3.3.1. Try to upgrade to a newer version.
This p:calendar is inside a h:form?
We had the exact same problem and noted that we had forget this

Primefaces prevent/disable editing in schedule

How do you prevent editing/moving events on the schedule?
I could reset the date on the moveEvent() but this would not stop someone from dragging it.
Thanks
1) DRAGGING: Use the draggable attribute of <p:schedule> set it to false or bind it to a bean property.
2) Editting: remove the listener from the eventSelect.
<p:schedule value="#{scheduleController.eventModel}" draggable="false" widgetVar="myschedule">
<p:ajax event="dateSelect" listener="#{scheduleController.onDateSelect}" oncomplete="eventDialog.show()" />
<!-- <p:ajax event="eventSelect" listener="NOBODY" update="NOTHING" Oncomplete="REMOVE ME" /> -->
<p:ajax event="eventMove" listener="#{scheduleController.onEventMove}" update="formNotificacao" />
<p:ajax event="eventResize" listener="#{scheduleController.onEventResize}" update="formNotificacao" />
</p:schedule>
PS: you did not specify PF version, i am using 3.3.1
PS2: if you leave the commented line your JSF may throw an error www.mkyong.com/jsf2/how-to-use-comments-in-jsf-2-0/

Reset input fields in primefaces

I have a Dialog to input details. At the first time , InputText are empty.
But from the second input, InputText maintain the previous value.
This is my code :
<p:commandButton id="showDialogButton1" type="button" value="add" onclick="dlg1.show()" update="firstname1"/>
<p:dialog id="dialogAjout" header="add department" widgetVar="dlg1" resizable="false">
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel for="firstname1" value="Libellé :" />
<p:inputText id="firstname1" value="#{departementBean.departement.libelleDepartement}" />
</h:panelGrid>
<p:commandButton id="submitButton1" value="Valider" oncomplete="dlg1.hide();" action="#{departementBean.addDept()}" update="tabView"/>
</p:dialog>
How can I resolve this, please !!
You can use this primefaces component:
http://www.primefaces.org/showcase/ui/misc/resetInput.xhtml
Regarding dialogs in general: don't put them inside forms.
Have this instead: <p:dialog><h:form>...
Regarding update="" values, if your appendToBody is true, put a colon in front of the id (that means it`s in another form).
You should use the following code:
<h:commandButton value="Reset" style="margin-right:20px;">
<p:ajax update="registrationForm" resetValues="true" />
</h:commandButton>
Add resetValues="true" to your commandButton
<p:commandButton resetValues="true" action="#{departementBean.prepareDialog}" id="showDialogButton1" type="button" value="add" oncomplete="dlg1.show()" update=":dialogAjout"/>
modify you open button like this : open dialog in oncomplete and before that update it by adding its id to update attribute and add action method to do the server side logic to actually init the dialog fields (populate / reset)
<p:commandButton action="#{departementBean.prepareDialog}" id="showDialogButton1" type="button" value="add" oncomplete="dlg1.show()" update=":dialogAjout"/>
b.t.w it looks like your dialog located inside your form together with your opening button , this is a "bad practice" move your dialog away from that form and place a new form inside the dialog , e.g <p:dialog><h:form> ...
I solved this question thus
<p:dialog header="myDialog" widgetVar="dlg1" minHeight="40">
<h:outputLabel for="fild1" value="Fill the field" />
<p:password id="fild1" value="#{myBean.attribute}" required="false" label="Field" redisplay="false" /><br />
<p:commandButton action="#{myBean.method()}" value="Send" oncomplete="dlg1.hide()" update="field1" />
</p:dialog>
When I used the attribute update="field1" of p:commandButton.
The value of field p:password will empty after submitting the form.
I tried do the suggestion of Dani but my attribute going empty when I submitted my form and not stayed empty after submit