Search Results

Search found 270 results on 11 pages for 'joao pedro portelinha'.

Page 9/11 | < Previous Page | 5 6 7 8 9 10 11  | Next Page >

  • TransactionRequiredException on OptimisticLockException

    - by João Madureira Pires
    Hi there. I have the following class that generates sequencial Card Numbers. I'm trying to recover from OptimisticLockException, by calling recursively the same method. however, i'm getting TransactionRequiredException. Dows anyone knows how to recover from OptimisticLockException in my case? Thanks a lot in advance @Name("simpleAutoIncrementGenerator") public class SimpleAutoIncrementGenerator extends CardNumberGenerator{ private static final long serialVersionUID = 2869548248468809665L; private int numberOfRetries = 0; @Override public String generateNextNumber(CardInstance cardInstance, EntityManager entityManager) { try{ EntityCard card = (EntityCard)entityManager.find(EntityCard.class, cardInstance.getId()); if(card != null){ String nextNumber = ""; String currentNumber = card.getCurrentCardNumber(); if(currentNumber != null && !currentNumber.isEmpty()){ Long numberToInc = Long.parseLong(currentNumber); numberToInc ++; nextNumber = String.valueOf(numberToInc); card.setCurrentCardNumber(nextNumber); // this is just to cause a OptimisticLock Exception try { Thread.sleep(4000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } entityManager.persist(card); entityManager.flush(); return nextNumber; } } }catch (OptimisticLockException oLE) { System.out.println("\n\n\n\n OptimisticLockException \n\n\n\n"); if(numberOfRetries < CentralizedConfig.CARD_NUMBER_GENERATOR_MAX_TRIES){ numberOfRetries ++; return generateNextNumber(cardInstance,entityManager); } }catch (TransactionRequiredException trE) { System.out.println("\n\n\n\n TransactionRequiredException \n\n\n\n"); if(numberOfRetries < CentralizedConfig.CARD_NUMBER_GENERATOR_MAX_TRIES){ numberOfRetries ++; return generateNextNumber(cardInstance,entityManager); } }catch (StaleObjectStateException e) { System.out.println("\n\n\n\n StaleObjectStateException \n\n\n\n"); if(numberOfRetries < CentralizedConfig.CARD_NUMBER_GENERATOR_MAX_TRIES){ numberOfRetries ++; return generateNextNumber(cardInstance,entityManager); } } return null; } }

    Read the article

  • Fseek on C problem

    - by Pedro
    i'm testing this code, but doesn't work, it always says that an error occurred :S int main(int argc, char **argv) { FILE *file_pointer; file_pointer = fopen("text.txt","r"); if(fseek(file_pointer, 0, -1)) { puts("An error occurred"); } else { char buffer[100]; fgets(buffer, 100, file_pointer); puts("The first line of the file is:"); puts(buffer); } fclose(file_pointer); return 0; }

    Read the article

  • How to set the time for a specific local in javascript

    - by Joao
    Hi, i have a problem, and maybe someone can help me, i will explain... i have the in javascript "var date= new date();" and its give me the local time (browser time) but i want force this data/time for a especific local... for example... Spain. i want everytime that someone enter in the page (from others country) the date need be the spanish hour. i found some soluction but the problem is the summer time and winter time... we have offset variations because some time is +1 hours and others is +2.... someone can help me in one soluction? thanks [email protected]

    Read the article

  • Changing url of background image

    - by João Pedro
    I'm doing this interface where I have a lot of buttons that are just a li with a background image like this #menu ul.icons li.nove { background-image:url(images/edit-menu/icons/undo.png); background-size:contain; display:block; margin-top:29px; } <ul class="icons"> <li class="um"></li> <li class="dois"></li> <li class="tres"></li> <li class="quatro"></li> <li class="cinco"></li> <li class="seis"></li> <li class="sete"></li> <li class="oito"></li> <li class="nove"></li> <li class="dez"></li> </ul> I need to create a code where I change the background image of the button when the user clicks it, to show that button its activated, I just need to change url(images/edit-menu/icons/ to url(images/edit-menu/select/ and keep the same filename. I need a way to do this dynamically so I won't have to do it for each of the 10 buttons. Hope I was clear, thanks in advance

    Read the article

  • waiting for 2 different events in a single thread

    - by João Portela
    component A (in C++) - is blocked waiting for alarm signals (not relevant) and IO signals (1 udp socket). has one handler for each of these. component B (java) - has to receive the same information the component A udp socket receives. periodicaly gives instructions that should be sent through component A udp socket. How to join both components? it is strongly desirable that: the changes to attach component B to component A are minimal (its not my code and it is not very pleasent to mess with). the time taken by the new operations (usually communicating with component B) interfere very little with the usual processing time of component A - this means that if the operations are going to take a "some" time I would rather use a thread or something to do them. note: since component A receives udp packets more frequently that it has component B instructions to forward, if necessary, it can only forward the instructions (when available) from the IO handler. my initial ideia was to develop a component C (in C++) that would sit inside the component A code (is this called an adapter?) that when instanciated starts the java process and makes the necessary connections (that not so little overhead in the initialization is not a problem). It would have 2 stacks, one for the data to give component B (lets call it Bstack) and for the data to give component A (lets call it Astack). It would sit on its thread (lets call it new-thread) waiting for data to be available in Bstack to send it over udp, and listen on the udp socket to put data on the Astack. This means that the changes to component A are only: when it receives a new UDP packet put it on the Bstack, and if there is something on the Astack sent it over its UDP socket (I decided for this because this socket would only be used in the main thread). One of the problems is that I don't know how to wait for both of these events at the same time using only one thread. so my questions are: Do I really need to use the main thread to send the data over component A socket or can I do it from the new-thread? (I think the answer is no, but I'm not sure about race conditions on sockets) how to I wait for both events? boost::condition_variable or something similar seems the solution in the case of the stack and boost::asio::io_service io_service.run() seems like the thing to use for the socket. Is there any other alternative solution for this problem that I'm not aware of? Thanks for reading this long text but I really wanted you to understand the problem.

    Read the article

  • Difficulty with sql query

    - by João Madureira Pires
    I have the following tables: TableA (id, tableB_id, tableC_id) TableB (id, expirationDate) TableC (id, expirationDate) I want to retrieve all the results from TableA ordered by tableB.expirationDate and tableC.expirationDate. How can I do this?

    Read the article

  • How to change object positions in an android layout?

    - by Pedro Santos
    Hi, I'm currently working on a very simple aplication, and I intended to make it change the visual aspect depending on the screen size. The application just has 6 buttons like this: http://www.freeimagehosting.net/uploads/e1efb4c4d0.jpg I'm using the AbsoluteLayout, and changing the x and y of the buttons with the methods offsetLeftAndRight and offsetTopAndBottom. I'm not changing the layout of the buttons in the xml file, so the all start in the same place. However, if I use this methods inside the onClickMethod they sometimes appear where I want them, sometimes don't (can't figure out why), but if i use them in the onCreate method, nothing happens. Can someone point me in the right direction? Thanks

    Read the article

  • Decompiling an old Program

    - by Pedro Laranjeiro
    Hi. I have been asked to update a program written in 1987 in Delphi (I guess). I have no documentation about this program only a few side notes the programmer took that don't make too much sense to make. The cd show this files: Size | Filename - 19956 VP.DTA - 142300 VP.LEX - 404 VP.NDX - 126502 VP.RCS - 131016 VP.SCR - 150067 VP.XEL - 101791 vp.exe Is anyone of this files a database? If so can I access it's data? I tried several code decompilers but they show a message saying it was not a Win32 compatible application. The program run in MS-DOS. Is it possible to obtain the source code? Can I use this code in any way to build a new application? Thanks Update01: I can run the program in MSDOS. The program conjugate verbs and shows an example sentence where the verb can be used. The GUI is a little bit confusing and there is no help menu so I can't see all the capabilities of the program.

    Read the article

  • Facebook SSO authorize in safari but not in facebook app

    - by Pedro Calero
    My problem: I has developed an app with Facebook SSO in my iPhone/iPad. It was working OK. But I have changed the certificate of my app (so now it has new app ID). I also have changed the "iOS pack ID" property in Facebook: I deleted the old app ID and I added the new one. But now my app doesn't do the Facebook SSO when Facebook app is installed. It does it OK when Facebook app is not installed and it uses Safari. I have read this question and this question that say the problem is the "iOS pack ID" and app ID don't match. I have checked it a lot of times, and it is the same. I have put the old app ID in the "iOS pack ID" property of Facebook, but it still doesn't work. I don't know if Facebook take a time to check if my app ID is valid, and how they show the result. I have been a lot of time with this issue. It seem like the problem is the iOS pack ID is not exactly the app ID, but it is not the problem: they are exactly the same. Thank you very much.

    Read the article

  • In what circumstances are instance variables declared as '_var' in 'use fields' readonly?

    - by Pedro Silva
    I'm trying to understand the behavior of the fields pragma, which I find poorly documented, regarding fields prefixed with underscores. This is what the documentation has to say about it: Field names that start with an underscore character are made private to the class and are not visible to subclasses. Inherited fields can be overridden but will generate a warning if used together with the -w switch. This is not consistent with its actual behavior, according to my test, below. Not only are _-prefixed fields visible within a subclass, they are visible within foreign classes as well (unless I don't get what 'visible' means). Also, directly accessing the restricted hash works fine. Where can I find more about the behavior of the fields pragma, short of going at the source code? { package Foo; use strict; use warnings; use fields qw/a _b __c/; sub new { my ( $class ) = @_; my Foo $self = fields::new($class); $self->a = 1; $self->b = 2; $self->c = 3; return $self; } sub a : lvalue { shift->{a} } sub b : lvalue { shift->{_b} } sub c : lvalue { shift->{__c} } } { package Bar; use base 'Foo'; use strict; use warnings; use Data::Dumper; my $o = Bar->new; print Dumper $o; ##$VAR1 = bless({'_b' => 2, '__c' => 3, 'a' => 1}, 'Foo'); $o->a = 4; $o->b = 5; $o->c = 6; print Dumper $o; ##$VAR1 = bless({'_b' => 5, '__c' => 6, 'a' => 4}, 'Foo'); $o->{a} = 7; $o->{_b} = 8; $o->{__c} = 9; print Dumper $o; ##$VAR1 = bless({'_b' => 8, '__c' => 9, 'a' => 7}, 'Foo'); }

    Read the article

  • why does Visual Studio not enforce try-catch-block implementation?

    - by Pedro
    Coming from Eclipse/Java, I noticed that in VisualStudio/C# it is not mandatory to care about Exceptions. While Eclipse forces the user to implement a try-catch-block or to add a throws declaration, this is not the case in Visual Studio. What is the reason Visual Studio doesn't inform about unhandled exceptions? Can I configure Visual Studio to force me to implement try-catch-blocks, or at least add a compiler-warning?

    Read the article

  • In what circumstances are instance variables declared as '_var' in 'use fields' private?

    - by Pedro Silva
    I'm trying to understand the behavior of the fields pragma, which I find poorly documented, regarding fields prefixed with underscores. This is what the documentation has to say about it: Field names that start with an underscore character are made private to the class and are not visible to subclasses. Inherited fields can be overridden but will generate a warning if used together with the -w switch. This is not consistent with its actual behavior, according to my test, below. Not only are _-prefixed fields visible within a subclass, they are visible within foreign classes as well (unless I don't get what 'visible' means). Also, directly accessing the restricted hash works fine. Where can I find more about the behavior of the fields pragma, short of going at the source code? { package Foo; use strict; use warnings; use fields qw/a _b __c/; sub new { my ( $class ) = @_; my Foo $self = fields::new($class); $self->a = 1; $self->b = 2; $self->c = 3; return $self; } sub a : lvalue { shift->{a} } sub b : lvalue { shift->{_b} } sub c : lvalue { shift->{__c} } } { package Bar; use base 'Foo'; use strict; use warnings; use Data::Dumper; my $o = Bar->new; print Dumper $o; ##$VAR1 = bless({'_b' => 2, '__c' => 3, 'a' => 1}, 'Foo'); $o->a = 4; $o->b = 5; $o->c = 6; print Dumper $o; ##$VAR1 = bless({'_b' => 5, '__c' => 6, 'a' => 4}, 'Foo'); $o->{a} = 7; $o->{_b} = 8; $o->{__c} = 9; print Dumper $o; ##$VAR1 = bless({'_b' => 8, '__c' => 9, 'a' => 7}, 'Foo'); }

    Read the article

  • How to make cross-domain AJAX calls to Google Maps API?

    - by Pedro
    Hi everyone, I'm trying to make a jQuery $.getJSON call to the Google Maps Geocoding webservice, but this doesn't work because of cross-domain security issues. I haven't been able to figure it out online, but I've read a bit about Google Javascript API or JSONP, but so far no clear answer... Could anyone enlight me? Thanks!

    Read the article

  • Is there any "modern" text editor with command-line?

    - by Pedro Morte Rolo
    A command line in a text editor is a wonderful feature. It allows the user to explore the editor's functionality and learn it's shortcuts in a textual way. It's much faster than using the mouse, and it is much easier to memorise "shortcuts" this way. Emacs and VI provide this, though, emacs and vi are not "modern". By "modern", I mean one that is original built to cope with the modern de-facto standards of selecting, copying, pasting, cutting, undoing, redoing and auto-completing. Cream/vi or EmacsCUE are not valid options, since there are loads of things built over them that conflict with the mentioned stuff. Is there any alternative? (I do not intend to use the "modern" term as derrogatory. I love both Emacs and VI, but I hate their keyboard shortcut baggage.) (please do not advertise Vim and Emacs, that's not answering the question. I am asking for alternatives)

    Read the article

  • how to use use case relations - uml

    - by joao alves
    Heys guys! Im have been study UML and im trying to to design the use case diagram of a problem. Lets supose my app consists in this: Two Requesites: - create teams - create players This is the deal: A user can create a team, and after create a team he can create players for that team(not required). But in this app there are multiple users, and a user can create a team and other user can create players. The only constraint is that to create players must exist alreay a team. I research and i end up a little confuse. If i get the concepts of relations on use case diagrams right, i think i should have the folowwing two use cases: [use case - create team] <-------extends---- [use case - create player] I need opinions,Is this the proper solution? or should i have two not related use cases? Thanks in advance, and im sorry my english.

    Read the article

  • C programing fopen

    - by Pedro
    #include <stdio.h> #include <stdlib.h> typedef struct aluno{ char cabecalho[60]; char info[100]; int n_alunos; char dados[100]; char curso[100]; int numero; char nome[100]; char e_mail[100]; int n_disciplinas; int nota; }ALUNO; void cabclh(ALUNO alunos[],int a){ FILE *fp; int i; for(i=0;i<100;i++){ fp=fopen("trabalho.txt","r"); } if(fp==NULL){ printf("Erro ao abrir o ficheiro\n"); } while(!feof(fp)){ fgets(alunos[i].cabecalho,100,fp); printf("%s\n",alunos[i].cabecalho); } } fclose(fp); } what is wrong here? main: int main(int argc, char *argv[]){ ALUNO alunos[100]; int aluno; int b; cabclh(aluno,b); system("PAUSE"); return 0

    Read the article

  • Load image from server on a UIImageView in phone

    - by Pedro Narvaez
    Hi.. I'm having a problem loading a remote image into a UIImageVIew... It just doesn't show the image, may be i'm missing something... I also use the described here but with the same results How to load image from remote server on the UIImageView in iphone? Can someone help me? This is the code i'm using Im getting the data from a xml and on the image element I have the full path [[detailViewController detailImage] setImage:[UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: [NSString stringWithFormat:@"%@", [[promoList objectAtIndex: promoIndex] objectForKey: @"image"]] ]]] ]; With this code the image are displayed correctly [[detailViewController detailImage] setImage:[UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: @"http://localhost/promos/preview/1.jpeg"]] ]];

    Read the article

  • Difficults on sql query

    - by João Madureira Pires
    I have the following tables: TableA (id, tableB_id, tableC_id) TableB (id, expirationDate) TableC (id, expirationDate) I want to retrieve all the results from TableA ordered by tableB.expirationDate and tableC.expirationDate. thanks

    Read the article

  • How can I pipe two Perl CORE::system commands in a cross-platform way?

    - by Pedro Silva
    I'm writing a System::Wrapper module to abstract away from CORE::system and the qx operator. I have a serial method that attempts to connect command1's output to command2's input. I've made some progress using named pipes, but POSIX::mkfifo is not cross-platform. Here's part of what I have so far (the run method at the bottom basically calls system): package main; my $obj1 = System::Wrapper->new( interpreter => 'perl', arguments => [-pe => q{''}], input => ['input.txt'], description => 'Concatenate input.txt to STDOUT', ); my $obj2 = System::Wrapper->new( interpreter => 'perl', arguments => [-pe => q{'$_ = reverse $_}'}], description => 'Reverse lines of input input', output => { '>' => 'output' }, ); $obj1->serial( $obj2 ); package System::Wrapper; #... sub serial { my ($self, @commands) = @_; eval { require POSIX; POSIX->import(); require threads; }; my $tmp_dir = File::Spec->tmpdir(); my $last = $self; my @threads; push @commands, $self; for my $command (@commands) { croak sprintf "%s::serial: type of args to serial must be '%s', not '%s'", ref $self, ref $self, ref $command || $command unless ref $command eq ref $self; my $named_pipe = File::Spec->catfile( $tmp_dir, int \$command ); POSIX::mkfifo( $named_pipe, 0777 ) or croak sprintf "%s::serial: couldn't create named pipe %s: %s", ref $self, $named_pipe, $!; $last->output( { '>' => $named_pipe } ); $command->input( $named_pipe ); push @threads, threads->new( sub{ $last->run } ); $last = $command; } $_->join for @threads; } #... My specific questions: Is there an alternative to POSIX::mkfifo that is cross-platform? Win32 named pipes don't work, as you can't open those as regular files, neither do sockets, for the same reasons. 2. The above doesn't quite work; the two threads get spawned correctly, but nothing flows across the pipe. I suppose that might have something to do with pipe deadlocking or output buffering. What throws me off is that when I run those two commands in the actual shell, everything works as expected. Point 2 is solved; a -p fifo file test was not testing the correct file.

    Read the article

  • C - 3rd line on a txt

    - by Pedro
    Hi....I have on the txt file this: Hello Experience 3 Bad Hi want to scanf the 3rd line; i'm doing this: FILE *fp; int number; fp=fopen("test.txt","r"); if(fp==NULL){ printf("Error\n"); } while(!feof(fp)){ for(i=0;i<=3;i++){ if(i==3){ fscnaf(number,fp); prinf("string in the 3rd line is %s\n",number); } } } system("PAUSE"); } I need to use the fscanf, because i will need it, the number is the size of students in a school... Something is wrong, but i don't know what is...please help me...

    Read the article

  • Check if a type is an instantiation of a template

    - by Pedro Lacerda
    I have structs like struct RGBA (T) {/* ... */} struct BMPFile (DataT) if (is(DataT == RGBA)) {/* ... */} But is(DataT == RGBA) cannot work because DataT is a type and RGBA is a template. Instead I need check if a type is an instantiation of a template in order to declare file like BMPFile!(RGBA!ushort) file; In a comment @FeepingCreature showed struct RGBA(T) { alias void isRGBAStruct; } struct BMPFile (DataT) if (is(DataT.isRGBAStruct)) {} Although to be working I have no tips on alias void isRGBAStruct.

    Read the article

  • Shopping Cart with multiple orders in ASP

    - by Joao Heleno
    I'm building an e-commerce website in ASP.Net/C# and I'm having some difficulties with my shopping cart... I want my costumers to be able to say "I want X boxes, and each box carries Y items". Let's say, for instance, my website sells flowers. A client logs in and then chooses X bouquets and then for each bouquet he adds flowers from the catalog. Can you point me out some links or tips in order to achieve this behaviour? Thanks

    Read the article

< Previous Page | 5 6 7 8 9 10 11  | Next Page >