Fórum

Show alert instead of error

Wolfgang Duttlinger, modificado 11 Anos atrás.

Show alert instead of error

New Member Postagens: 9 Data de Entrada: 30/08/12 Postagens Recentes
Hi,

In portlet code I create an error with following code:

SessionErrors.add(request, "no-subject-found");


In JSP i display the error using the liferay-ui:error tag:

<liferay-ui:error key="no-subject-found" message="no-subject-found" />


Instead of the red message box i want the text to be displayed in the yellow box, that is used for alerts



What is the best way to do so? Is there something like a liferay-ui:alert tag?
thumbnail
Vitaliy Koshelenko, modificado 11 Anos atrás.

RE: Show alert instead of error

Expert Postagens: 319 Data de Entrada: 25/03/11 Postagens Recentes
You can use Liferay css style for alerts (portlet-msg-alerts) on your JSP page:
<div class="portlet-msg-alert">
Alert message here
</div>
Wolfgang Duttlinger, modificado 11 Anos atrás.

RE: Show alert instead of error

New Member Postagens: 9 Data de Entrada: 30/08/12 Postagens Recentes
Thanks a lot Vitaliy.

I tried this code:
<div class="portlet-msg-alert">
	<liferay-ui:error key="no-subject-found" message="no-subject-found" />
</div>


And I got this result:


I think your proposal would work, if I used text instead of the liferay-ui:error tag. However, in this case I would loose the opportunity to use liferay's built-in error system.

Any further proposals?
thumbnail
Pankaj Kathiriya, modificado 11 Anos atrás.

RE: Show alert instead of error

Liferay Master Postagens: 722 Data de Entrada: 05/08/10 Postagens Recentes
Hi,

You may use css fix for this.
Override .portlet-msg-error class's background and border properties to none for that portlet only.

For example have css class name as
#id .portlet-msg-error

id would be element id of some top level html element of portlet page.


OR

If you want that alert type message instead error type throughout the portal then simply in theme override css class .portlet-msg-error class and set it as same as .portlet-msg-alert. OR
override html\taglib\ui\error\start.jsp and instead
<div class="portlet-msg-error">
keep
<div class="portlet-msg-alert">
.

HTH,
Thanks,
Pankaj
Wolfgang Duttlinger, modificado 11 Anos atrás.

RE: Show alert instead of error

New Member Postagens: 9 Data de Entrada: 30/08/12 Postagens Recentes
Thanks a lot Pankaj, you pointed me to the right direction.

in view.jsp I put a div with id "myAlert" around my liferay-ui:error tag:

<div id="myAlert">
	<liferay-ui:error key="no-subject-found" message="no-subject-found" />
</div>


And in custom.css i added this code:

#myAlert.portlet-msg-error {
	background: #FFC url(../images/messages/alert.png) no-repeat 6px 20%;
	border: 1px solid #FC0;
}


And the error finaly gets display as an alert in the yellow box emoticon
Abdulbasit Shaikh, modificado 9 Anos atrás.

RE: Show alert instead of error

New Member Postagens: 18 Data de Entrada: 16/05/13 Postagens Recentes
Thanks a lot pankaj.

Thanks and Regards,
Abdulbasit F Shaikh.
thumbnail
Andrew Jardine, modificado 8 Anos atrás.

RE: Show alert instead of error

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
I'm using 6.2 and and this is how I did it (using the css that Liferay provides out of the box)


<div id="alert alert-warning">
    <liferay-ui:message key="no-subject-found" />
</div>


.. this didn't have the icon though so to add that you can do ..


<div id="alert alert-warning">
    <liferay-ui:icon image="../messages/alert" /> <liferay-ui:message key="no-subject-found" />
</div>


.. don't put the .png on the image attribute. Liferay does that for you -- as I learned the hard way.
thumbnail
srikanth a, modificado 11 Anos atrás.

RE: Show alert instead of error

Regular Member Postagens: 144 Data de Entrada: 21/02/11 Postagens Recentes
Hi ,
I f you want to show your error message in an alert box then it is better to use the message key option and get the value from the property files.
Even the error ui tag does same thing. Only it adds the div tags with the corresponding css class around your message key.

So i advise you to get the property value from the file and achieve your result. Any other proposals are most welcomed.


regards
Sri