Primefaces: Growl is displayed without the icon - primefaces

When growl is displayed (in the example below, showing the message 'Chart updated') the icon does not appear. There are no error messages in the console. This happens in a single page, the rest of the application works fine. What could be wrong?
UPDATE: the page is loaded as an iframe
This is how the growl is declared:
<p:growl life="2000" id="messages" for="msg1" showDetail="true"/>
and the java:
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage fm = new FacesMessage("Chart updated", "");
context.addMessage("msg1", fm);

You need to add the Severity of your FacesMessage. You can use the following constructor:
FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_INFO,
"Message header", "Message detail")
Cheers.

Related

p:dialog show message or reload

In a jsf 2.2 primefaces application, I have a link that opens a dialog that has a form. On submission of the form, I want to close the dialog and reload the current page or show an error on the dialog itself.
The managedbean method is a void method that sets the status using RequestContext - addcallbackparam.
As the dialog submission happens using actionlistener and the remainder of the operation happens in javascript, I can’t quite handle this.
I followed the example provided on primefaces website.
https://www.primefaces.org/showcase/ui/overlay/dialog/loginDemo.xhtml
Can anyone provide any information.
Here is something you can try without using addcallbackparam and javascript..
On validation success, hide the dialog & reload page or on failure, set a warning message as below from managed bean:
public void login(ActionEvent event) {
if(username != null && username.equals("admin") && password != null && password.equals("admin")) {
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.execute("PF('dlg').hide()");
pageReload();
} else {
dialogWarning = "Validation failed";
}
}
public void pageReload() {
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
try {
ec.redirect(((HttpServletRequest) ec.getRequest()).getRequestURI());
} catch (IOException ex) {
//catch and log IO exception here
}
}
In the xhtml dialog set dynamic=true and display the warning message as below and add this id to the update attribute in the Login component.
<h:outputLabel id="warnMsgLabel" value="#userLoginView.dialogWarning" />

PrimeFaces openDialog not working properly within nested dialogs

I’m using PrimeFaces 6.0 and I’ve found a problem using nested dialogs. RequestContext.openDialog is not working properly. It doesn’t throw any exception, but it doesn’t open the dialog.
I built 5 pages (P1 to P5) based on the same Full Page Layout. Each page contains a p:dataTable. The p:dataTable has a p:column with a p:commandButton to open the next page in a new dialog. This is what I’ve found: on some of those pages the button of the first row doesn’t work; the buttons of the rest of the rows work properly.
The problem doesn’t seem to be inherent to the row data. When the button of the first row fails, it fails regardless the row that is being showed there. Rows can be sorted in different ways (so the first one would vary) and the button of the first row will continue failing and the rest of the buttons will continue working. The problem doesn’t seem to be inherent to the page either. All buttons work properly when the page is root (the one that opens the first dialog). The problem only happens within a dialog.
This is the button:
<p:commandButton
icon="fa fa-folder-open"
action="#{ambientePrueba11.openDialog(currentRow)}"
partialSubmit="true"
process="#this"
update="#none">
<p:ajax
event="dialogReturn"
listener="#{ambientePrueba11.onDialogReturn}"
update="dataTable"/>
</p:commandButton>
This is the code in the backing bean (each of the 5 beans have a different outcome, but the rest of the code is the same):
public String openDialog(AmbientePrueba row) {
EventLogger.log(this, "openDialog", getDenominacion(row));
Object identificacion = getIdentificacion(row);
String key = "PaquetePrueba11";
String outcome = FacesUtils.getPageKeyFacesOutcome(key);
Map<String, Object> options = new HashMap<>();
options.put("modal", true);
options.put("resizable", true);
options.put("draggable", true);
options.put("width", 1260);
options.put("height", 860);
options.put("contentWidth", "100%");
options.put("contentHeight", "100%");
options.put("closable", true);
options.put("includeViewParams", true);
options.put("minimizable", true);
options.put("maximizable", true);
Map<String, List<String>> params = new HashMap<>();
params.put(CPP.ID_RECURSO, toList(identificacion));
params.put(CPP.ID_RECURSO_MAESTRO, toList(identificacion));
params.put(Global.PARAMETRO_FRAMEWORK_SESION, toList(getSessionFrame()));
params.put(Global.PARAMETRO_CONDICION_SESION, toList(MODAL));
RequestContext.getCurrentInstance().openDialog(outcome, options, params);
return null;
}
private List<String> toList(Object value) {
List<String> paramValue = new ArrayList<>();
paramValue.add(value + "");
return paramValue;
}
public void onDialogReturn(SelectEvent event) {
Object response = event.getObject();
facesLogger.info(response + "");
}
Has anybody else found a similar problem? Any help to solve or workaround this problem will be very much appreciated.
After some more tests I found a work around. I just gave the button a different id in each page and now all the buttons of all the pages work just fine.
Now the button of page P1 (as its id suggests) looks like this:
<p:commandButton
id=buttonOfPage1
icon="fa fa-folder-open"
action="#{ambientePrueba11.openDialog(currentRow)}"
partialSubmit="true"
process="#this"
update="#none">
<p:ajax
event="dialogReturn"
listener="#{ambientePrueba11.onDialogReturn}"
update="dataTable"/>
</p:commandButton>

Message alert in windows phone 8

How to implement a message box like a alert box when button gets clicked or tiles get tapped.
also messagebox or alertbox contain buttons into my windows phone 8 application.
To show an alert you can use,
MessageDialog msgbox = new MessageDialog("Message to be displayed.");
await msgbox.ShowAsync();
Just take a look at the msdn.
There you can get an example and further details about MessageBox.Show Method (String, String, MessageBoxButton):
MessageBoxResult result =
MessageBox.Show("Would you like to see the simple version?",
"MessageBox Example", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
MessageBox.Show("No caption, one button.");
}
Or a overview about the whole MessageBox class.

making charts interactive in primefaces3

Trying to make my p:barChart interactive and getting jQuery.js.jsf script error in the browser window.
I added the following code as per the primefaces lab showcase to make my chart interactive,
java service code:
public void itemSelect(ItemSelectEvent event) {
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Item selected",
"Item Index: " + event.getItemIndex() + ", Series Index:" + event.getSeriesIndex());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
I use Primefaces3.M2 release and JSF2.
Can anybody help me fix this.

LinkButton not accessing EventArg

I am using c#.net.
I am trying to create a LinkButton within the code-behind, when I debug my code I recieve no errors, however its not accessing the EventArg attached to the button, it does however refresh the page. What am I doing wrong?
Button Code
LinkButton myLinkButton = new LinkButton();
myLinkButton.ID = appointment.appID.ToString();
myLinkButton.CommandArgument = appointment.appID.ToString();
myLinkButton.Command += new CommandEventHandler(ViewClick);
myLinkButton.CommandName = appointment.appID.ToString();
myLinkButton.Text = appointment.contactName
Used to style button
string divLook = "height:" + divHeight + "em";
Button is then added to a panel
Panel p = new Panel();
p.Style.Add("linkStyle", divLook);
p.CssClass = "standardLink";
p.Controls.Add(myLinkButton);
dataCell.Controls.Add(p);
protected void ViewClick(object sender, CommandEventArgs e)
{
var appointmentId = Convert.ToInt32(e.CommandArgument);
Debug.Write("Are you even getting in here");
}
Thanks in advance for any help.
Clare
Everything looks legit. I would recommend viewing the source of the generated page and looking at the ID that the link button is getting. It may be duped on the page.