I developed a component on backend, and now I faced a problem that I can't see a system message after data is updated. I suppose I had missed something like a message box or some code but still can't define exactly what it is. Can anybody tell me which data is necessary to get those messages?
// Get a handle to the Joomla! application object
$application = JFactory::getApplication();
// Add a message to the message queue
$application->enqueueMessage(JText::_('SOME_ERROR_OCCURRED'), 'error');
/** Alternatively you may use chaining */
JFactory::getApplication()->enqueueMessage(JText::_('SOME_ERROR_OCCURRED'), 'error');
The second argument to the enqueueMessage function is the type of the message. The default is 'message', but 'error' results in a different style for the message. The message will be displayed in place of a special jdoc:include statement in your template. Place the following in your template at the location where you want messages to appear.
<jdoc:include type="message" />
Read more
Related
My question is about handling "database validation errors" to the user using a Vuex store. (see image below)
Any advice on how to handle this ?
Then display my errors specified and "positioned" by field.
Something like this:
<label>Title</label>
<input type="text">
<p v-if="errors.title">{{errors.title}}</p>
My first thought was to pass the 'db errors' received by the 'vuex store action' too a 'store state attribute', and use a computed property with a "store getter" in the vuejs component to display the error, but this just doesn't feel right to me.
I use this json model for getting data from the server: {status: 0, result: {}, error: {}}.
In that case you can check the status attribute, for the success of the rest api call. So depends on the status, you can handle either the error, or the result variable.
On the server side, if any error / exception caught, you can send back to the client (specifically), in the error variable.
In your case, e.g.: you caught a db error on a server side, you define status for that (e.g.) 430, you send back the message with the error and the status code, that way you can handle nicely the problem.
I hope it helps! :)
I am using jqgrid and using the inline editing mode and can't figure out how to return errors back to the client from server side validation rules
I use fluent validation on my serverside to validate before persisting to a database. This works great except I don't see how to return errors when editing in inline mode. If I don't persist the values to the databse, the client still shows the value which should be rejected.
What is the recommended way to return an error after someone commits an inline edit so you will get some popup on the client side showing the error and it will stay in edit state ?
NOTE: this image below is in response to Oleg's comment and answer below
The recommend way is to use any HTTP error code in the response on the submitting of wrong data and to return the error description in the body of the response. If you need some more specific action like displaying another dialog with the error information, setting of focus on a field, marking some fields with CSS class 'ui-state-error' or something like that you should use errorfunc callback function.
If restoreAfterError is false the inline editing will be continued.
UPDATED: I mention in comments that the server should produce the error message as the response. In case of ASP.NET MVC the default message is HTML text which you posted as the first picture. If you use HandleJsonExceptionAttribute which I described in my old answer the error message will be serialized as JSON, but it contains additional information which you don't need to display (like the StackTrace). So you should use errorfunc parameter of editRow or saveRow to decode the server response. You can either use decodeErrorMessage from the already referenced answer or use the $.parseJSON function directly:
errorfunc: function(rowid, res) {
var errorText = $.parseJSON(res.responseText).Message;
$.jgrid.info_dialog($.jgrid.errors.errcap,
'<div class="ui-state-error">' + errorText + '</div>',
$.jgrid.edit.bClose,
{buttonalign: 'right'});
}
I have a variety of functions within my models which serve a different purpose.
One for example looks up the data for a given $_GET variable in the URL string.
I am trying to work out a way of displaying an error message if there is no matching row in the database due to url string manipulation for example.
My first idea was simply to return an error message (if there is an error) with each call to the function, then simply have an if statement whereby if there is an error, an error view is shown, and if not the normal view is shown..
Problem with this is that this function is called numerous times in my controller, and other similar functions are called throughout my code which need similar error handling..
I dont want millions of similar if/else statements all over my code to handle errors..
Anyone got any better ideas?
Cheers
Use the flashdata item of the session class. You can concatenate error messages and put them in the flashdata item to display.
my_function(){
// code that determines if there is an error returns => $error
if ($error)
{
// concat previous and current errors
$new_error = $this->session->flashdata('errors') . $error;
// replace 'errors' with newly concatenated errors
$this->session->set_flashdata('errors', $new_error);
}
}
This will keep track of all errors generated through each request and allow you to display a "list" of errors for that particular request.
echo $this->session->flashdata('errors');
In my magento website As soon as someone places order , an email is sent to his/her emailid. In the email the subject is correct but there is no body in the message, i mean the message comes blank.
i added new template from Transactional Emails section and associated this template with the Order from configuration->sales emails. but still my subject of the template reaches to mails but not the body. the message body remains empty always.
please help me solve this issue
thanks in advance
Looks like there is some error during rendering the email template. Try to replace your email template body with something simple.
Magento doesn't trigger any error when the template is not returned/processed properly.
The trace is:
Mage/Sales/Model/Order.php - sendNewOrderEmail()
Mage/Core/Model/Email/Template/Mailer.php - send()
Mage/Core/Model/Template.php - send()
Some things to check first - is the email valid for send, see the conditions below:
public function isValidForSend()
{
return !Mage::getStoreConfigFlag('system/smtp/disable')
&& $this->getSenderName()
&& $this->getSenderEmail()
&& $this->getTemplateSubject();
}
Another thing to look for:
If you copy-pasted some of the email content you might have some characters in the email that are not ASCII. This causes a crash when the template is parsed and there is no error logged/displayed.
This can be checked by using the standard Magento email template and if that works and your custom template doesn't.
I found that the cause of the error was the vars:
{{config path='trans_email/ident_support/email'}}
{{config path='general/store_information/phone'}}
If these are deleted/substituted, then the emails are being sent without errors.
I've been search for quite a while and haven't been able to find an answer to this.
I am using asp.net MVC 3 with unobtrusive validation. My model is bound with data annotations for simple validation (required fields, regex, etc..). However, I have more complex validation that occurs on the server. I'm doing an ajax post which returns me validation add'l messages that come from my domain model. All I want to do is put those validation messages on the form in the place of the existing ones. I don't want to use partial views since all I've really got are messages coming back and there isn't a need to refresh the whole view. Also, I'm not adding new rules or new inputs to the form so $.validator.unobtrusive.parse won't work. These are just messages I want to put on the form. The $.post call returns a list of message with which field is/was affected and the validation message.
Here's kind of what I'm looking to do
$.post(url, { someData}, function (data) {
for (message in data.Messages) {
$("#form").validate().addMessage(message.Field, message.Text);
}
});
Thanks for your help
Per request, here's a sample of the returning JSON, it's fairly simple.
{"id":0,"messages":["Level":0,"Message":"Style is required","Name":"Style"}],"operationResult":false}
messages is a list of objects that contain the severity level, the property the error belonged to and the error message. I would use the name in the messages object to match where it want on the form.
I had exactly the same requirement, I actually found the following method.
var validator = $("form").validate();
validator.showErrors({field : "Error Message"})