Posts by utluiz • 72,075 points
957 posts
-
3
votes1
answer109
viewsA: "Noinitialcontextexception" error while boosting GWT application via Eclipse
After researching about the error, I realized that the same occurs in this environment due to the order of loading the dependencies in classpath of the execution. The solution was to access the menu…
-
5
votes2
answers351
viewsA: How to Interact Javascript + jQuery with CSS
With jQuery and CSS, you can recover HTML and set this content as text: $('.classe').text($('.classe').html()) And then set a CSS for the font to get the correct spacing: .classe { display: block;…
-
3
votes8
answers2292
viewsA: Why create an object using the superclass?
The advantages of using abstraction are the same as the polymorphism, that in my view the main one is the creation of generic routines that do not need to know the specific types. This allows you to…
-
3
votes4
answers7006
viewsA: Doubt with Regex with new line
This depends on the language you are running. Each has a way of specifying that the dot should include end-of-line characters. The concept of dot all causes the dot to consider line breaks, but we…
-
0
votes3
answers346
viewsA: How to make a polymorphic pointer with the this pointer in the parameter?
The example of QLabel with the parameter this makes sense if the code is being executed in the context of a class that may contain a QLabel, an instance of QWidget, since the first parameter would…
-
4
votes5
answers411
viewsA: How to avoid a comparison by brute force?
I wouldn’t have a problem with the IFs for a system-specific routine with a very limited scope. It would be the cleanest and most efficient. But if the idea is to spice up your system with a little…
-
7
votes2
answers275
viewsA: Performance of string substitution
I added two more substitution techniques who do not use regular expressions at the jsperf original by Sergio. split/Join var resultado = texto.split('azul').join('verde'); index var pos =…
javascriptanswered utluiz 72,075 -
2
votes2
answers944
viewsA: Mock Static method with Demoiselle and Powermock/Mockito
I have never used the Demoiselle Framework. However, the difficulty with multiple Runners is not uncommon and occurs with other frameworks. One solution is to use the Powermockrule. According to the…
-
3
votes5
answers62952
viewsA: How to remove edge of input and textarea from all browsers when clicked?
Use the attribute outline CSS, as in the example: input, textarea, select { outline: 0; } See the jsfiddle.…
-
3
votes2
answers2560
viewsA: Accessing another controller’s variable - Cakephp
Accessing variables from other controllers is completely different from accessing their methods or actions. The controllers Cakephp’s are just common classes, so in theory, you could access your…
-
2
votes4
answers8200
viewsA: How to send text to the printer with PHP and Javascript?
As already mentioned, it is not possible to use Javascript to send commands to the printer, requiring a language with lower-level access to the operating system to execute communication directly…
-
1
votes1
answer818
viewsA: Pass updated information from subreport to parent report
I do not think it is necessary to create a three-level report. You can solve this by creating a query that makes the Join of the three tables and create two groups, one for city and one for…
-
9
votes3
answers10991
viewsA: How to escape quotes in Postgresql?
Simply duplicate the single quotes to generate one escape. Example: f_criaproduto(' meu produto é ''televisao'' da melhor qualidade')…
-
3
votes1
answer1384
viewsA: Error deploying to Wildfly
The class org.hibernate.jpa.HibernatePersistenceProvider is available as of version 4.3 of Hibernate. Before that, the preview correct is:…
-
3
votes1
answer401
viewsA: Is it possible to use timestamp without having to convert to String on Oracle?
According to a oracle documentation there are the date literals. I put together a simple query to illustrate: SELECT DATE '1998-12-25', TIMESTAMP '1984-03-01 09:26:50.124' FROM DUAL; I got the…
-
8
votes4
answers7550
viewsA: jQuery identifying jQuery’s own change
As already mentioned, changing the value via Javascript does not trigger the change event. An alternative is to run the desired code along with the value change instead of relying on the event.…
-
4
votes4
answers775
viewsA: Static service class in web application
"Static classes", or classes containing static general utility methods, are an interesting option for some common tasks. Personally, I have a habit of encapsulating some routines in this way. Just…
-
3
votes2
answers437
viewsA: When do I use Objectoutputstream the parent class attributes are also saved?
When it comes to inheritance, there are some nuances as to what will or will not be included in serialization. The ObjectOutputStream will serialize all hierarchy classes that are marked with…
-
2
votes2
answers122
viewsA: Changes directly in the database reflect in the bean Managed?
First, check that the change is isolated in an unaffected transaction. If so, do the commit for the values to be read correctly by the application. It may still be occurring if the values are in…
-
65
votes6
answers20131
viewsA: Difference between single and double quotes in PHP
Single quotes The PHP documentation defines that single quotes are simple literal, unprocessed. The only exceptions for escape are the single quotes themselves ('\'') and the bar ('\\'). Example:…
-
1
votes3
answers364
viewsA: How to get the class name where a bean will be injected?
I have never seen injecting log class this way. I see no need to inject the log, since there should be an instance for the class. Just create a logger for each class in a private attribute by the…
-
4
votes8
answers4914
viewsA: Do not allow saving image of a web page
Some sites like Flickr, photographers' websites, crafts and others have some protection mechanisms to prevent anyone with no computer experience save available photos. Unfortunately, people of…
-
4
votes3
answers1447
viewsA: Fork in Join in Java
Fork/Join Functionality fork/join, present from Java 7, it can be a little difficult to understand at first, as it attends a specific class of problems. According to class documentation…
-
2
votes2
answers3020
viewsQ: How to request Python 3 via an HTTP proxy
In Python, we can recover the contents of a URL in a very simple way: from urllib import request response = request.urlopen('http://www.google.com') However, in corporate environments we cannot…
-
2
votes2
answers3020
viewsA: How to request Python 3 via an HTTP proxy
Python 3 solution using urllib You can create a request using a opener which, in turn, receives information from a Proxyhandler: from urllib import request #configura um "opener" com um proxy proxy…
-
6
votes6
answers8117
viewsA: How to remove a "href" from a <a> tag with Jquery/Javascript?
I suggest, in addition to removing the attribute, adding a style to be visible to the user: $('#link').removeAttr('href').css({ 'cursor': 'not-allowed', 'color': '#AAAAAA', 'text-decoration':…
-
1
votes1
answer1197
viewsA: Check runtime with timeit
You can use include the literal value of the parameter string in the function of the defendant timeit using the method format(), thus: "comp_string('{0}', 'Fred')".format(string) The full function…
-
4
votes2
answers1015
viewsQ: How to make a request by sending cookie data?
I want to file a requisition GET for a particular URL, but I want to send cookie data, as a web browser does. For example, in the code below: from urllib import request req =…
-
2
votes2
answers1015
viewsA: How to make a request by sending cookie data?
I was able to partially resolve the issue with the method add_header of the object request. from urllib import request req = request.Request('http://servidor/pagina.html') req.add_header('Cookie',…
-
3
votes1
answer783
viewsA: Delete log files with a date later than a week using log4j
Solution #1 - Switch to RollingFileAppender The class RollingFileAppender has the attribute MaxBackupIndex, which does exactly what you need, that is, limit log history to a certain number. Example:…
-
1
votes2
answers2721
viewsA: How to write in a text file concatenating with existing text in Java?
Before building the BufferedWriter, create a FileWriter with the parameter append of builder with the value true: new BufferedWriter(new FileWriter("foo.out", true));…
-
7
votes1
answer1549
viewsA: Mysql query equal to one value or another
Instead of the operator IN, you can use the CASE to check if a record exists. It’s like making a IF in a structured language. Take an example: SELECT CASE WHEN EXISTS(select cor from cores where cor…
-
3
votes3
answers403
viewsA: What is the benefit of working with webSql?
I may be mistaken, but today it does not seem to have any advantage, since the body that maintained the standard (W3C) abandoned the project for lack of variety of implementations. Apparently, all…
-
3
votes1
answer1120
viewsA: How to prevent the List.size() method from running lazyload with Hibernate and JPA
Solution ignoring the attribute when serializing After seeing the comment and understanding the problem better, I think the solution is to ask the Json library to ignore the attributes with the…
-
15
votes4
answers35413
viewsA: How to check events between 2 dates in Mysql?
Use the operator BETWEEN to facilitate and convert DATETIME for DATE. Example: SELECT titulo FROM eventos WHERE '2014-02-01' BETWEEN date(inicio) AND date(fim) See the example on sqlfiddle. The…
-
7
votes2
answers4977
views -
2
votes4
answers702
viewsA: What are the best practices of representing SQL within PHP code?
Each form has advantages and disadvantages. Text file At the time when I was developing a PHP framework, I thought a lot about the possibility of storing darlings in text files. This would reinforce…
-
2
votes1
answer527
viewsA: Configure the Jackson library for dynamic attributes
You can use the annotation @JsonAnySetter in a kind if Setter special associated with a Map. According to the documentation itself, the method with this annotation will serve as a fallback when an…
-
51
votes4
answers106387
viewsA: How to compare Strings in Java?
Playing with the == and with the pool strings Java uses a mechanism called String interning, putting the strings in a pool to try to store only one copy of each string in memory. When Java finds…
-
11
votes2
answers14288
viewsA: How to disable a text field for editing using jQuery/Javascript?
Browser does not send disabled fields with disabled in the submission of the form, so your first attempt did not work. On the other hand, you do not need to use script to prevent changing a field.…
-
3
votes3
answers1664
viewsA: How to use a Cookie as an Array in Javascript?
A reliable way would be to transform the array to a String in JSON format: var Foo = [1,2]; var FooStr = JSON.stringify(Foo); var OtherFoo = JSON.parse(FooStr) The only drawback of this approach…
-
1
votes4
answers3156
viewsA: How do I create an sql view with more than two tables?
I found the query below at this link: SELECT ce.*, ea.attribute_code, cev.value FROM customer_entity AS ce LEFT JOIN eav_attribute AS ea ON ce.entity_type_id = ea.entity_type_id AND ea.backend_type…
-
1
votes1
answer317
views -
2
votes9
answers2644
viewsA: Best practice for creating if
As @Lizard correctly mentioned, performance depends on the probability of the condition and also on the optimization that the processor is able to do. However, I would add here the frequency of use…
-
7
votes3
answers16338
viewsA: How to create and read an XML with Python?
You can use the library xml.dom.minidom. I made the following implementation in Python 3.3 to read an XML: from xml.dom import minidom xml ="""<raiz> <itens> <item…
-
17
votes8
answers3054
viewsA: When to use Waterfall and when to use Scrum?
I’m going to risk contributing to this controversial issue, especially after reading Victor’s response. I want to refute his argument, but at the same time fully agree with it. How? Waterfall is…
-
2
votes7
answers19609
viewsA: How to catch an element inside an iframe?
As they have said you cannot access the contents of a frame or iframe from another domain via Javascript for security reasons. The example you put on Plunker didn’t work because the domain where the…
-
1
votes3
answers1538
viewsA: Download event problem in "href"
Solution Listing Files by ID of a Table I imagine you have a chart or a way to make one from/to file ID for its respective path (path). Let’s assume you have the table with the fields ID and…
-
4
votes5
answers6040
viewsA: What tool to use to convert a visually developed UML to code?
The Eclipse Modeling Tools is an Eclipse distribution made especially for modeling, which includes UML 2.0. Just download the package.…
-
5
votes4
answers1904
viewsA: How to control when localstorage data expires?
Apparently it is not possible to set expiration for data in localStorage. Constant use of storage Usually you will have a finite set of stored items and will update them when necessary, keeping the…