Posts by Victor T. • 1,251 points
48 posts
-
0
votes1
answer62
viewsA: Use user-selected content in Combobox as key (map) in Enum class
Try the following: first, create the redenderer: class TipoItemRenderer extends BasicComboBoxRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, int index,…
-
2
votes2
answers775
viewsA: How to save user session by logging in using Java +Angularjs
Use the ngStorage: var meuApp = angular.module("meuApp", ["ngStorage"]); meuApp.controller("LoginController", function($scope, $localStorage) { $scope.login = function() { $localStorage.usuario =…
-
0
votes3
answers1781
viewsA: How to validate a double field?
It is no use just checking if the value is empty; the correct is to check if the String sent is actually a number. In your role verificaDados(): Alter: if(valor.equals("")) {…
-
2
votes2
answers86
viewsA: How to choose date in timestamp
One option is to use the function DateTime::add: $dataQualquer = new DateTime(); $dataQualquer->add(new DateInterval('PT10M')); // 10 minutos no futuro echo…
-
1
votes2
answers68
viewsA: Group two tables
One option is to use a subselect: SELECT p.nome, p.email, (SELECT COUNT(*) FROM eventos e WHERE e.pessoa_id = p.pessoa_id) AS qtde_eventos FROM pessoas p ORDER BY p.nome…
postgresqlanswered Victor T. 1,251 -
1
votes1
answer181
viewsA: Darcula look and Feel in the application
Relationship this jar in his class path, and then: BasicLookAndFeel darcula = new DarculaLaf(); UIManager.setLookAndFeel(darcula);…
-
1
votes1
answer776
viewsA: How can I clean the buffer?
Alternatives to fflush: fseek(stdin, 0, SEEK_END); Or else: while (getchar() != '\n');
-
1
votes1
answer57
viewsA: Problem with TIMER insertion in Mysql table using JDBC
One option is to use the function ADDTIME mysql: UPDATE vagas set tempo = :tempo, ttotal = ADDTIME(ttotal, :tempo) WHERE nomeID = :nomeID Notice that we are using named Parameters, that should be…
-
1
votes1
answer320
viewsA: Add Primefaces to the project
No need to lower the jar on your PC. Just include the following dependencies in your pom.xml (the theme is optional): <dependency> <groupId>org.primefaces</groupId>…
-
1
votes1
answer614
viewsA: Java project problems with CDI (Weld) + Hibernate + Primefaces
We’re missing a lib in your project. If you are a Maven project, add the following dependency: <dependency> <groupId>org.jboss</groupId> <artifactId>jandex</artifactId>…
-
1
votes1
answer37
viewsA: Jlabel of visual bug when use setBackground()
To paint Swing components, they must be marked as opaque (not transparent). Confirmed if the JPanel is marked as opaque? jPanel.setOpaque(true);
-
1
votes2
answers1282
viewsA: Shell/Bash - Script continues before finishing the line that is running
You can ask the SSH client to inform the server that it is active (Alive) each n seconds by inserting the following option: ssh -o ServerAliveInterval=30 $USER_SSH@$HOST_SSH ... In this example: 30…
-
1
votes1
answer119
viewsA: SELECT in postgresql does not take records in the time range
I believe your problem is still the time zone issue, as your return from now() ends with +00, and our zone (America/Sao_paulo) is -03. Try the following: SELECT * FROM motoqueiros WHERE now() AT…
postgresqlanswered Victor T. 1,251 -
1
votes3
answers88
viewsA: Timer does not run when changing computer date
The java.util.Timer is dependent on the date and time of the system operational. If you happen to return the time, I believe that according to this bug, It’ll just stop working. A viable option is…
-
2
votes1
answer76
viewsA: How to apply a scope to a dynamically created element in Angularjs?
You must compile your template, specifying the scope of the compilation. This is done through the service $compile. angular.module('app', []).controller('TestCtrl', function ($scope, $compile) {…
-
0
votes2
answers326
viewsA: Start function and run function again by clicking the button
Remove the function initMapplic of the page loading scope: function initMapplic(title) { // ... } $(document).ready(function() { initMapplic(''); $("#searchfilters").on('click', function() {…
-
5
votes1
answer1956
viewsA: Iterative sum bigdecimal
Adriano, in the BigDecimal it is impossible to use the operator +. Use add(): valorTotal = BigDecimal.ZERO; for (...) { valorTotal = valorTotal.add(lista.get(i).getValorItem()); } If you’re on Java…
-
1
votes2
answers1232
viewsA: How to change persistence.xml file settings through an external file?
I believe that the best solution is to inform your connection settings in Tomcat, not in the project. Following documentation of Tomcat 7: Within the Context of your application, create a Resource…
-
3
votes1
answer215
viewsA: CEP database
I’ve used the Viacep, is free and works with HTTPS: http://viacep.com.br/. Example: http://viacep.com.br/ws/01001000/json/ { "cep": "01001-000", "logradouro": "Praça da Sé", "complemento": "lado…
-
0
votes1
answer49
viewsA: How to create a Rigger After Update
You cannot mess with the data of the table itself that activated the trigger (Trigger). The solution is to create a Trigger before update: DELIMITER ;; CREATE TRIGGER `e-sms-db`.`esms_conta_b_u`…
-
0
votes1
answer59
viewsA: Problem with JSF Redirect 2
The Omnifaces has a Feature calling for FullAjaxExceptionHandler, that redirects you to the page you choose if given Exception was created. Example: public String getBla() { if (bla == null) { throw…
-
2
votes2
answers406
viewsA: Memory consumption in java
You are remaking statements within the loop. Go to declare outside the loop: final Calendar calendario = new GregorianCalendar(); final Date dt = calendario.getInstance().getTime(); final…
-
7
votes2
answers890
viewsA: How to add parallelism in execution with the subprocess module?
A guess using thread: import thread def listen(s): try: while True: data = s.recv(1024) # a central de controle envia tb o "Enter" que teclamos apos cada comando {\n} #print(data) if data[:-1] ==…
-
2
votes2
answers805
viewsA: Group by by two fields ordered by a third
I don’t have SQL Server installed, but I tested with Mysql and you should be able to with a similar SQL: SELECT t2.* FROM (SELECT user, deviceid, MAX(date) AS date FROM q144255 GROUP BY user,…
-
0
votes2
answers994
viewsA: How to also treat accented strings and without accents in a LIKE
Try the following: SELECT * FROM tabela WHERE coluna LIKE 'a%' COLLATE utf8_unicode_ci;
-
3
votes1
answer339
viewsA: Get the current page name with JSF 2
One option is through ExternalContext: ((HttpServletRequest) getFacesContext().getExternalContext().getRequest()).getRequestURI()
-
0
votes1
answer579
views -
0
votes2
answers836
viewsA: JSF - How to pass a Bean function as an argument to a Javascript function?
Thaylon, specify a Listener through an event ajax: <p:dialog id="suaDialog" widgetVar="suaDialog" header="Sua Dialog" resizable="false" showEffect="clip" hideEffect="clip"> <p:ajax…
-
4
votes3
answers1710
viewsA: When and why should we use threads?
Keep in mind that every program already has at least one thread, which is the thread main (where it is running). There are a thousand and one reasons to use thread, and each programmer should know…
-
0
votes1
answer88
viewsA: Can anyone tell us why this Lazarus/Pascal code is a mistake?
In Object Pascal, the correct is to use property, thus: unit uPais; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Dialogs; type Pais = class private fCodigo: Integer; // por convenção insira…
-
4
votes2
answers88
viewsA: Change Preposition According to State
Although somewhat archaic, it would work with array: <?php $uf = "São Paulo"; $preposicoes = array( "Rio de Janeiro" => "do", "São Paulo" => "de"); // complete com os demais estados echo…
-
6
votes1
answer2530
viewsA: Show DIV according to PHP condition
Option 1: <div style="<?php echo get('data_do_descredenciamento') != '' ? 'show' : 'none'; ?>"> </div> Option 2: <div style="<?php if (get('data_do_descredenciamento') == '')…
-
0
votes3
answers720
viewsA: Nullpointerexception Java JPA CDI Tomcat
Write down your class EspecialidadeWS with @javax.enterprise.context.RequestScoped to function as web service. EDIT: In my projects I use the Resteasy together with the CDI to run the injection you…
-
1
votes2
answers234
viewsA: Trigger that accumulates the Mysql result
Gabriel, it will be necessary to use a CURSOR in Mysql. It’s hard to get it right without testing, but Trigger would look something like this: DELIMITER // CREATE TRIGGER upd_etapa AFTER UPDATE ON…
-
0
votes2
answers642
viewsA: When I install apk it is installing more than once the app
Run on the terminal: adb uninstall br.com.seuapp Then do the deploy normally.
-
3
votes1
answer2343
viewsA: Create Trigger update Mysql
In practice, to set the field tab_a.campo_a = tab_b.campo_b + 1, would look something like this: DELIMITER // CREATE TRIGGER upd_tab_b BEFORE UPDATE ON tab_b FOR EACH ROW BEGIN UPDATE tab_a SET…
-
1
votes1
answer6947
viewsA: Android Studio Error "Unable to locate adb"
Go to the menu Tools > Android > SDK Manager, and then access the tab SDK Tools and check whether Android SDK Platform-Tools is installed (not sure if I’m with the latest version of Android…
android-studioanswered Victor T. 1,251 -
4
votes3
answers2128
viewsA: Send PHP variable to Shell Script
Pass the data through arguments, which can be read in bash scripts over $1, $2, etc. Your bash script would look like this: #!/bin/bash NAME="$1" DIR="$2" tar -zcf $NAME.tar.gz $DIR In PHP, enter…
-
4
votes1
answer727
viewsA: What is the memory limit of php 7?
According to the manual: memory_limit integer Sets the maximum amount of memory in bytes a script is allowed to allocate. This helps prevent scripts badly written consume all available memory on the…
-
5
votes5
answers163
viewsA: Is there a tool to make html manuals easy to update?
Currently, there are new proposals such as Doclets and the DAUX, cloud tools that greatly facilitate the generation of manuals and documentation.…
-
6
votes3
answers1174
viewsA: Conversion of variables type int to char*. C++
You can do with sprintf: #include <stdio.h> void exemplo(int i1, int i2) { char s[16]; sprintf(s, "%d%d", i1, i2); printf(s); } void main() { exemplo(12, 34); }…
-
1
votes3
answers89
viewsA: SQL - Doubt in a query
EDIT 2: SELECT cod, nome, MIN(menorregistro) AS menorregistro FROM ( SELECT b.pront AS cod, d.nome, b.dt_ate, MIN(IIF(b.dt_ate BETWEEN '2015-12-19' AND '2016-01-08', b.reg, NULL)) AS menorregistro…
-
1
votes1
answer2757
viewsA: Read JSON and print to html with Angularjs
The response of the request, injected into the variable sponse, does not contain the list of values you expect. According to the documentation available in…
-
3
votes1
answer91
views -
1
votes1
answer347
viewsA: Validate with object Annotations within a method
IMHO, what you’re doing is reinventing the wheel. In an object-oriented language, assuming you are using some persistence model, it seems to me more correct to create a Functio class and its…
-
0
votes1
answer114
viewsA: null return when trying to persist data
From what I understood in the log, the problem is not at the moment of persistence, but when you access the product registration page and there is not yet a product selected,…
-
1
votes2
answers1233
viewsA: Error reading java properties file
Your problem is in detecting the path correct file . properties in the project. The point is that the way you are accessing the file, it should be in the working directory, which can be accessed…
-
1
votes4
answers2941
viewsA: Primefaces datatable number formatting
I believe that creating a converter that saves only the numbers is the simplest way to solve this issue. package br.com.t2tecnologia; import javax.faces.component.UIComponent; import…