Popup in Jhipster
I don't know how to edit this popup , I can't find the file where it is modified. I use react for the front-end
Notification content is built by java backend in REST controller and passed to client through HTTP headers (i18n message key and its params)
.headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString()))
When frontend receives response, the popup is built in notification-middleware.ts, the message key is extracted for translation to retrieve localized message template and then the params are injected to produce final localized text:
toast.success(translate(alert, { param: alertParam }));
You can see the headers when inspecting the response in the browser's console.
So, if you want to change the text for one entity, you must modify the message with "created" key in src/main/webapp/i18n/<Language>/<Entity name>.json for each language that your app supports.
Related
I'm building an API with Symfony 3 following the JSON API specification (Documentation).
When submitting new data, the request has this format :
{
"type": "entity",
"id" : null,
"attributes" : {
"name" : "Test name"
}
}
But the problem is the request does not fit the format expected by symfony's Forms because of the extra object attributes.
So I want to be able to transform the request before the form submit in order to make the form able to populate the underlying Entity.
I have tried to register an FormEvents:PRE_SUBMIT and do the logic in it but it seems I have no access to the Request content.
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
$data = $event->getData();
var_dump($data);
die();
});
The $event->getData() is null.
I have also see there is possibility to register DataTransformer but it is registered per field, and has no access to the Request too.
I don't want to do it manually in the Controller as this will occur on all my forms (or at least the majority), so I search for a more generic way to transform the request, but at this point I can't figure out how to do this.
Thanks for help.
Your EventListener does not have access to your Request, nor does your Form itself.
The best and cleanest way to do this in my opinion would be to define a custom RequestHandler for your Forms, extending the NativeRequestHandler that parses your Request by default.
Then you only need to execute $builder->setRequestHandler() to apply this to your Forms.
i use primefaces on jsf framework, i have in my database a field that save the url source of where the image was saved for example:
Table Person:
id: integer
name: varchar
img: varchar ("C:\images\person\person1.jpg")
so, in my method in java y return that url string but when i put to the graphic image label
it load like this http://localhost:8080/..../C:\images\person\person1.jpg
any ideas???
<p:graphicImage value="#{person.img}"/>
this line is in pure html
<img src="C:\images\person\person1.jpg" alt=""/>
It seems that you're expecting that image to be served by the default servlet or as a JSF resource since it's on your filesystem. This won't happen unless that imagine is part of your web-app.
In order to serve it, return a StreamedContent object from your method, something like this return new StreamedContent(new FileInputStream(getPathFromDatabase()));. Note that the returned property should be available in session scope or request scope, because the image is served by the Primefaces resource handler in a separate request. This means that if you return the StreamedContent object from a view scoped bean, it won't be available on subsequent requests.
The value attribute of graphicImage is a relative url (or a binary stream if you implement StreamedContent), relative to your context.
That means it is appended to the url of your application, resulting in something like: http://hostname:port/appname/relative_image_url.
I want to intercept console log message from AngularJS and display them in a div on the page. I need this in order to debug ajax traffic in a PhoneGap app.
This is an example of the kind of errors I want to capture:
I tried this Showing console errors and alerts in a div inside the page but that does not intercept Angular error messages.
I also tried the solution gameover suggested in the answers. No luck with that either. Apparently $http is handling error logging differently.
I guess the answer you tried has the right idea but you're overriding the wrong methods. Reading here I can see angularJs uses $log instead of console.log, so to intercept you can try to override those.
Something like this:
$scope.$log = {
error: function(msg){document.getElementById("logger").innerHTML(msg)},
info: function(msg){document.getElementById("logger").innerHTML(msg)},
log: function(msg){document.getElementById("logger").innerHTML(msg)},
warn: function(msg){document.getElementById("logger").innerHTML(msg)}
}
Make sure to run that after importing angular.js.
EDIT
Second guess, override the consoleLog method on the LogProvider inner class on angular.js file:
function consoleLog(type) {
var output ="";
//arguments array, you'll need to change this accordingly if you want to
//log arrays, objects etc
forEach(arguments, function(arg) {
output+= arg +" ";
});
document.getElementById("logger").innerHTML(output);
}
I've used log4javascript for this purpose. I create the log object via
var log = log4javascript.getLogger('myApp')
log.addAppender(new log4javascript.InPageAppender());
I then use this in a value dependency, and hook into it where needed (e.g. http interceptor).
A more lightweight approach might be to use $rootScope.emit and then have a component on your main page which prepends these log messages to a visible div, but this will require you to change all your calls to console.log (or redefine the function in your js).
I think that this message is not even displayed from AngularJS. It looks like an exception which has not been caught in any JavaScript (angular.js just appears on top of your stack because that's the actual location where the HTTP request is being sent).
Take a look at ng.$exceptionHandler. That should be the code you seem to be interested in. If not, take a quick web search for „JavaScript onerror“ which should tell you how to watch for these kinds of errors.
I would rather user an $http interceptor.
Inside the responseError function, you can set a property on a service that will be exposed to the div's scope.
I'm trying to post an array using a POST request to a specific page, the target page generates a csv and send me back the stream, right now i'm doing using ExtJs Ajax class, but that won't work as i need to make a normal HTTP request not ajax, my current code is as follows:
Ext.extend(Players.panel.Home,MODx.Panel,{
exportSubscribers: function(btn,e) {
MODx.Ajax.request({
url: Players.config.connectorUrl
,params: {
action: 'mgr/player/getSubscribers'
}
});
}
});
The exportSubscribers function is executed from a normal ExtJs button
{ xtype: 'button'
,text: 'Export Subscribers'
,preventRender: true
,handler: this.exportSubscribers
}
What class should i use to turn this into a normal request?
Thanks.
There isn't a class to do a normal request. I known two ways to accomplish a file download:
Use a hidden form in the page, replace the field values and invoke the form's .sumbit method from ExtJS button handler to do the POST request you want.
Replace your button by an HTTP anchor if you can use a GET request to make the server return the file: Download CSV'
You'd be better off making a local request to your server, and then in your server-side code make a cURL request to the CSV source. That way, you can make a non XMLHttpRequest method to get your data.
I am using the WebBrowser control on a Windows Forms application in Visual Studio 2010 - targeting .Net framework 3.5.
I have loaded the contents of the WebBrowser control via setting the DocumentStream property. The stream content is from the response to an Http (POST) request to a third party web page which is called in code using the HttpWebRequest object. We need to use the POST request verb type. The form is populated with data based on the request parameters.
Within the Windows application, the user needs to fill out a few additional text fields and then submit. Having been loaded via the stream, the page has no knowledge of full url of the original page. Therefore the submit fails (displays the name of the page in the WebBrowser control).
Is there any way to give the control the full path to the document such that the Submit operation will have the correct context? Setting WebBrowser.Url property does not work as this simply results in navigation to the page without the data displayed as it is not passed any parameters.
Below is the code (so far):
//Class to call website to make http post
var webBridge = new WebCallHandler();
//Make the request. Response returned as string
var result = webBridge.MakeHttpRequest();
//Get string as stream
var byteArray = Encoding.ASCII.GetBytes(result);
var stream = new MemoryStream(byteArray) { Position = 0 };
//webBrowser1.Url = new Uri(URL);
webBrowser1.DocumentStream = stream;
//Need to set the context of the page like "http://example.com/somepage.aspx"
var dom = webBrowser1.Document.DomDocument;
If you have filled the result variable (which seems to be a string), you should rather easily be able to modify the contents.
Using e.g. Regular Expressions or HTML Agility Pack to search for the
<form ... action="relative-url" ...
and replace it with
<form ... action="http://somedomain.com/relative-url" ...
then pass it to the DocumentStream property of your browser.
I searched the string being returned from the HttpWebrequest for the form element action attribute. This only showed the name of the page received from the httpWebRequest. I modified it in code to be the full url.
Thanks for your comment Kevin. This was the prompt that helped.