Search Results

Search found 908 results on 37 pages for 'iterator'.

Page 19/37 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • JSF: Cannot catch ViewExpiredException

    - by ifischer
    I'm developing a JSF 2.0 application on Glassfish v3 and i'm trying to handle the ViewExpiredException. But whatever i do, i always get a Glassfish error report instead of my own error page. To simulate the occurrence of the VEE, i inserted the following function into my backing bean, which fires the VEE. I'm triggering this function from my JSF page through a commandLink. The Code: @Named public class PersonHome { (...) public void throwVEE() { throw new ViewExpiredException(); } } At first i tried it by simply adding an error-page to my web.xml: <error-page> <exception-type>javax.faces.application.ViewExpiredException</exception-type> <location>/error.xhtml</location> </error-page> But this doesn't work, i'm not redirected to error but i'm shown the Glassfish errorpage, which shows a HTTP Status 500 page with the following content: description:The server encountered an internal error () that prevented it from fulfilling this request. exception: javax.servlet.ServletException: javax.faces.application.ViewExpiredException root cause: javax.faces.el.EvaluationException:javax.faces.application.ViewExpiredException root cause:javax.faces.application.ViewExpiredException Next thing i tried was to write ExceptionHandlerFactory and a CustomExceptionHandler, as described in JavaServerFaces 2.0 - The Complete Reference. So i inserted the following tag into faces-config.xml: <factory> <exception-handler-factory> exceptions.ExceptionHandlerFactory </exception-handler-factory> </factory> And added these classes: The factory: package exceptions; import javax.faces.context.ExceptionHandler; public class ExceptionHandlerFactory extends javax.faces.context.ExceptionHandlerFactory { private javax.faces.context.ExceptionHandlerFactory parent; public ExceptionHandlerFactory(javax.faces.context.ExceptionHandlerFactory parent) { this.parent = parent; } @Override public ExceptionHandler getExceptionHandler() { ExceptionHandler result = parent.getExceptionHandler(); result = new CustomExceptionHandler(result); return result; } } The custom exception handler: package exceptions; import java.util.Iterator; import javax.faces.FacesException; import javax.faces.application.NavigationHandler; import javax.faces.application.ViewExpiredException; import javax.faces.context.ExceptionHandler; import javax.faces.context.ExceptionHandlerWrapper; import javax.faces.context.FacesContext; import javax.faces.event.ExceptionQueuedEvent; import javax.faces.event.ExceptionQueuedEventContext; class CustomExceptionHandler extends ExceptionHandlerWrapper { private ExceptionHandler parent; public CustomExceptionHandler(ExceptionHandler parent) { this.parent = parent; } @Override public ExceptionHandler getWrapped() { return this.parent; } @Override public void handle() throws FacesException { for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) { ExceptionQueuedEvent event = i.next(); System.out.println("Iterating over ExceptionQueuedEvents. Current:" + event.toString()); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); if (t instanceof ViewExpiredException) { ViewExpiredException vee = (ViewExpiredException) t; FacesContext fc = FacesContext.getCurrentInstance(); NavigationHandler nav = fc.getApplication().getNavigationHandler(); try { // Push some useful stuff to the flash scope for // use in the page fc.getExternalContext().getFlash().put("expiredViewId", vee.getViewId()); nav.handleNavigation(fc, null, "/login?faces-redirect=true"); fc.renderResponse(); } finally { i.remove(); } } } // At this point, the queue will not contain any ViewExpiredEvents. // Therefore, let the parent handle them. getWrapped().handle(); } } But STILL i'm NOT redirected to my error page - i'm getting the same HTTP 500 error like above. What am i doing wrong, what could be missing in my implementation so that the exception is handled correctly?

    Read the article

  • issue with std::advance on std::sets

    - by tim
    I've stumbled upon what I believe is a bug in the stl algorithm advance. When I'm advancing the iterator off of the end of the container, I get inconsistent results. Sometimes I get container.end(), sometimes I get the last element. I've illustrated this with the following code: #include <algorithm> #include <cstdio> #include <set> using namespace std; typedef set<int> tMap; int main(int argc, char** argv) { tMap::iterator i; tMap the_map; for (int i=0; i<10; i++) the_map.insert(i); #if EXPERIMENT==1 i = the_map.begin(); #elif EXPERIMENT==2 i = the_map.find(4); #elif EXPERIMENT==3 i = the_map.find(5); #elif EXPERIMENT==4 i = the_map.find(6); #elif EXPERIMENT==5 i = the_map.find(9); #elif EXPERIMENT==6 i = the_map.find(2000); #else i = the_map.end(); #endif advance(i, 100); if (i == the_map.end()) printf("the end\n"); else printf("wuh? %d\n", *i); return 0; } Which I get the following unexpected (according to me) behavior in experiment 3 and 5 where I get the last element instead of the_map.end(). [tim@saturn advance]$ uname -srvmpio Linux 2.6.18-1.2798.fc6 #1 SMP Mon Oct 16 14:37:32 EDT 2006 i686 athlon i386 GNU/Linux [tim@saturn advance]$ g++ --version g++ (GCC) 4.1.1 20061011 (Red Hat 4.1.1-30) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [tim@saturn advance]$ g++ -DEXPERIMENT=1 advance.cc [tim@saturn advance]$ ./a.out the end [tim@saturn advance]$ g++ -DEXPERIMENT=2 advance.cc [tim@saturn advance]$ ./a.out the end [tim@saturn advance]$ g++ -DEXPERIMENT=3 advance.cc [tim@saturn advance]$ ./a.out wuh? 9 [tim@saturn advance]$ g++ -DEXPERIMENT=4 advance.cc [tim@saturn advance]$ ./a.out the end [tim@saturn advance]$ g++ -DEXPERIMENT=5 advance.cc [tim@saturn advance]$ ./a.out wuh? 9 [tim@saturn advance]$ g++ -DEXPERIMENT=6 advance.cc [tim@saturn advance]$ ./a.out the end [tim@saturn advance]$ g++ -DEXPERIMENT=7 advance.cc [tim@saturn advance]$ ./a.out the end [tim@saturn advance]$ From the sgi website (see link at top), it has the following example: list<int> L; L.push_back(0); L.push_back(1); list<int>::iterator i = L.begin(); advance(i, 2); assert(i == L.end()); I would think that the assertion should apply to other container types, no? What am I missing? Thanks!

    Read the article

  • Issue Parsing File with YAML-CPP

    - by Andrew
    In the following code, I'm having some sort of issue getting my .yaml file parsed using parser.GetNextDocument(doc);. After much gross debugging, I've found that the (main) issue here is that my for loop is not running, due to doc.size() == 0; What am I doing wrong? void BookView::load() { aBook.clear(); QString fileName = QFileDialog::getOpenFileName(this, tr("Load Address Book"), "", tr("Address Book (*.yaml);;All Files (*)")); if(fileName.isEmpty()) { return; } else { try { std::ifstream fin(fileName.toStdString().c_str()); YAML::Parser parser(fin); YAML::Node doc; std::map< std::string, std::string > entry; parser.GetNextDocument(doc); std::cout << doc.size(); for( YAML::Iterator it = doc.begin(); it != doc.end(); it++ ) { *it >> entry; aBook.push_back(entry); } } catch(YAML::ParserException &e) { std::cout << "YAML Exception caught: " << e.what() << std::endl; } } updateLayout( Navigating ); } The .yaml file being read was generated using yaml-cpp, so I assume it is correctly formed YAML, but just in case, here's the file anyways. ^@^@^@\230--- - address: ****************** comment: None. email: andrew(dot)levenson(at)gmail(dot)com name: Andrew Levenson phone: **********^@ Edit: By request, the emitting code: void BookView::save() { QString fileName = QFileDialog::getSaveFileName(this, tr("Save Address Book"), "", tr("Address Book (*.yaml);;All Files (*)")); if (fileName.isEmpty()) { return; } else { QFile file(fileName); if(!file.open(QIODevice::WriteOnly)) { QMessageBox::information(this, tr("Unable to open file"), file.errorString()); return; } std::vector< std::map< std::string, std::string > >::iterator itr; std::map< std::string, std::string >::iterator mItr; YAML::Emitter yaml; yaml << YAML::BeginSeq; for( itr = aBook.begin(); itr < aBook.end(); itr++ ) { yaml << YAML::BeginMap; for( mItr = (*itr).begin(); mItr != (*itr).end(); mItr++ ) { yaml << YAML::Key << (*mItr).first << YAML::Value << (*mItr).second; } yaml << YAML::EndMap; } yaml << YAML::EndSeq; QDataStream out(&file); out.setVersion(QDataStream::Qt_4_5); out << yaml.c_str(); } }

    Read the article

  • OSX: How to get a volume name (or bsd name) from a IOUSBDeviceInterface or location id

    - by LG
    Hi, I'm trying to write an app that associates a particular USB string descriptor (of a USB mass storage device) with its volume or bsd name. So the code goes through all the connected USB devices, gets the string descriptors and extracts information from one of them. I would like to get the volume name of those USB devices. I can't find the right API to do that. I have tried to do that: DASessionRef session = DASessionCreate(kCFAllocatorDefault); DADiskRef disk_ref = DADiskCreateFromIOMedia(kCFAllocatorDefault, session, usb_device_ref); const char* name = DADiskGetBSDName(disk_ref); But the DADiskCreateFromIOMedia function returned nil, I assume the usb_device_ref that I passed was not compatible with the io_service_t that the function is expecting. So how can I get the volume name of a USB device? Could I use the location id to do that? Thanks for reading. -L FOO_Result result = FOO_SUCCESS; mach_port_t master_port; kern_return_t k_result; io_iterator_t iterator = 0; io_service_t usb_device_ref; CFMutableDictionaryRef matching_dictionary = NULL; // first create a master_port if (FOO_FAILED(k_result = IOMasterPort(MACH_PORT_NULL, &master_port))) { fprintf(stderr, "could not create master port, err = %d\n", k_result); goto cleanup; } if ((matching_dictionary = IOServiceMatching(kIOUSBDeviceClassName)) == NULL) { fprintf(stderr, "could not create matching dictionary, err = %d\n", k_result); goto cleanup; } if (FOO_FAILED(k_result = IOServiceGetMatchingServices(master_port, matching_dictionary, &iterator))) { fprintf(stderr, "could not find any matching services, err = %d\n", k_result); goto cleanup; } while (usb_device_ref = IOIteratorNext(iterator)) { IOReturn err; IOCFPlugInInterface **iodev; // requires <IOKit/IOCFPlugIn.h> IOUSBDeviceInterface **dev; SInt32 score; err = IOCreatePlugInInterfaceForService(usb_device_ref, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &iodev, &score); if (err || !iodev) { printf("dealWithDevice: unable to create plugin. ret = %08x, iodev = %p\n", err, iodev); return; } err = (*iodev)->QueryInterface(iodev, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), (LPVOID*)&dev); (*iodev)->Release(iodev); // done with this FOO_String string_value; UInt8 string_index = 0x1; FOO_Result result = FOO_SUCCESS; CFStringRef device_name_as_cf_string; do { if (FOO_SUCCEEDED(result = FOO_GetStringDescriptor(dev, string_index, 0, string_value))) { printf("String at index %i is %s\n", string_index, string_value.GetChars()); // extract the command code if it is the FOO string if (string_value.CompareN("FOO:", 4) == 0) { FOO_Byte code = 0; FOO_HexToByte(string_value.GetChars() + 4, code); // Get other relevant information from the device io_name_t device_name; UInt32 location_id = 0; // Get the USB device's name. err = IORegistryEntryGetName(usb_device_ref, device_name); device_name_as_cf_string = CFStringCreateWithCString(kCFAllocatorDefault, device_name, kCFStringEncodingASCII); err = (*dev)->GetLocationID(dev, &location_id); // TODO: get volume or BSD name // add the device to the list break; } } string_index++; } while (FOO_SUCCEEDED(result)); err = (*dev)->USBDeviceClose(dev); if (err) { printf("dealWithDevice: error closing device - %08x\n", err); (*dev)->Release(dev); return; } err = (*dev)->Release(dev); if (err) { printf("dealWithDevice: error releasing device - %08x\n", err); return; } IOObjectRelease(usb_device_ref); // no longer need this reference }

    Read the article

  • Why does my finite state machine take so long to execute?

    - by BillyONeal
    Hello all :) I'm working on a state machine which is supposed to extract function calls of the form /* I am a comment */ //I am a comment perf("this.is.a.string.which\"can have QUOTES\"", 123456); where the extracted data would be perf("this.is.a.string.which\"can have QUOTES\"", 123456); from a file. Currently, to process a 41kb file, this process is taking close to a minute and a half. Is there something I'm seriously misunderstanding here about this finite state machine? #include <boost/algorithm/string.hpp> std::vector<std::string> Foo() { std::string fileData; //Fill filedata with the contents of a file std::vector<std::string> results; std::string::iterator begin = fileData.begin(); std::string::iterator end = fileData.end(); std::string::iterator stateZeroFoundLocation = fileData.begin(); std::size_t state = 0; for(; begin < end; begin++) { switch (state) { case 0: if (boost::starts_with(boost::make_iterator_range(begin, end), "pref(")) { stateZeroFoundLocation = begin; begin += 4; state = 2; } else if (*begin == '/') state = 1; break; case 1: state = 0; switch (*begin) { case '*': begin = boost::find_first(boost::make_iterator_range(begin, end), "*/").end(); break; case '/': begin = std::find(begin, end, L'\n'); } break; case 2: if (*begin == '"') state = 3; break; case 3: switch(*begin) { case '\\': state = 4; break; case '"': state = 5; } break; case 4: state = 3; break; case 5: if (*begin == ',') state = 6; break; case 6: if (*begin != ' ') state = 7; break; case 7: switch(*begin) { case '"': state = 8; break; default: state = 10; break; } break; case 8: switch(*begin) { case '\\': state = 9; break; case '"': state = 10; } break; case 9: state = 8; break; case 10: if (*begin == ')') state = 11; break; case 11: if (*begin == ';') state = 12; break; case 12: state = 0; results.push_back(std::string(stateZeroFoundLocation, begin)); }; } return results; } Billy3

    Read the article

  • How to kill android application using android code?

    - by Natarajan M
    I am develoing small android application in eclipse. In that project i kill the running process in android, i got the Permission Denial error. how can i solve this problem in android. Anybody help for this problem.... THIS IS MY CODE package com.example.nuts; import java.util.Iterator; import java.util.List; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager.RunningAppProcessInfo; import android.content.Context; import android.content.pm.PackageManager; import android.os.Bundle; import android.telephony.SmsManager; import android.widget.Toast; import android.*; public class killprocess extends Activity { SmsManager smsManager = SmsManager.getDefault(); Recivesms rms=new Recivesms(); String Number=""; int pid=0; String appname=""; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { Number=Recivesms.senderNum; pid=Integer.parseInt(Recivesms.struid); appname=getAppName(pid); Toast.makeText(getBaseContext(),"App Name is "+appname, Toast.LENGTH_LONG).show(); ActivityManager am = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE); List<RunningAppProcessInfo> processes = am.getRunningAppProcesses(); if (processes != null){ for (int i=0; i<processes.size(); i++){ RunningAppProcessInfo temp = processes.get(i); String pName = temp.processName; if (pName.equals(appname)) { Toast.makeText(getBaseContext(),"App Name is matched "+appname+" "+pName, Toast.LENGTH_LONG).show(); int pid1 = android.os.Process.getUidForName(pName); //android.os.Process.killProcess(pid1); am.killBackgroundProcesses(pName); Toast.makeText(getBaseContext(), "Killed successfully....", Toast.LENGTH_LONG).show(); } } } smsManager.sendTextMessage(Number, null,"Your process Successfully killed..." , null,null); }catch(Exception e) { Toast.makeText(getBaseContext(),e.getMessage(), Toast.LENGTH_LONG).show(); } } private String getAppName(int Pid) { String processName = ""; ActivityManager am = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE); List l = am.getRunningAppProcesses(); Iterator i = l.iterator(); PackageManager pm = this.getPackageManager(); while(i.hasNext()) { ActivityManager.RunningAppProcessInfo info = (ActivityManager.RunningAppProcessInfo)(i.next()); try { if(info.pid == Pid) { CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(info.processName, PackageManager.GET_META_DATA)); //Log.d("Process", "Id: "+ info.pid +" ProcessName: "+ info.processName +" Label: "+c.toString()); //processName = c.toString(); processName = info.processName; } } catch(Exception e) { //Log.d("Process", "Error>> :"+ e.toString()); } } return processName; } } After executing the code. i got the following error... Permission Denial: killBackgroundProcess() from pid=894, uid=10052 requires android.permission.KILL_BACKGROUND_PROCESSES Also i put the following line on manifest file <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESS" /> Anybody help for how to solve this problem... Thanking you....

    Read the article

  • Fill container with template parameters

    - by phlipsy
    I want to fill the template parameters passed to a variadic template into an array with fixed length. For that purpose I wrote the following helper function templates template<typename ForwardIterator, typename T> void fill(ForwardIterator i) { } template<typename ForwardIterator, typename T, T head, T... tail> void fill(ForwardIterator i) { *i = head; fill<ForwardIterator, T, tail...>(++i); } the following class template template<typename T, T... args> struct params_to_array; template<typename T, T last> struct params_to_array<T, last> { static const std::size_t SIZE = 1; typedef std::array<T, SIZE> array_type; static const array_type params; private: void init_params() { array_type result; fill<typename array_type::iterator, T, head, tail...>(result.begin()); return result; } }; template<typename T, T head, T... tail> struct params_to_array<T, head, tail...> { static const std::size_t SIZE = params_to_array<T, tail...>::SIZE + 1; typedef std::array<T, SIZE> array_type; static const array_type params; private: void init_params() { array_type result; fill<typename array_type::iterator, T, last>(result.begin()); return result; } }; and initialized the static constants via template<typename T, T last> const typename param_to_array<T, last>::array_type param_to_array<T, last>::params = param_to_array<T, last>::init_params(); and template<typename T, T head, T... tail> const typename param_to_array<T, head, tail...>::array_type param_to_array<T, head, tail...>::params = param_to_array<T, head, tail...>::init_params(); Now the array param_to_array<int, 1, 3, 4>::params is a std::array<int, 3> and contains the values 1, 3 and 4. I think there must be a simpler way to achieve this behavior. Any suggestions? Edit: As Noah Roberts suggested in his answer I modified my program like the following: I wrote a new struct counting the elements in a parameter list: template<typename T, T... args> struct count; template<typename T, T head, T... tail> struct count<T, head, tail...> { static const std::size_t value = count<T, tail...>::value + 1; }; template<typename T, T last> stuct count<T, last> { static const std::size_t value = 1; }; and wrote the following function template<typename T, T... args> std::array<T, count<T, args...>::value> params_to_array() { std::array<T, count<T, args...>::value> result; fill<typename std::array<T, count<T, args...>::value>::iterator, T, args...>(result.begin()); return result; } Now I get with params_to_array<int, 10, 20, 30>() a std::array<int, 3> with the content 10, 20 and 30. Any further suggestions?

    Read the article

  • How to mix textures in DirectX?

    - by tobsen
    I am new to DirectX development and I am wondering if I am taking the wrong route to achieve the following: I would like to mix three textures which contain transparent areas and some solid areas (Red, Blue, Green). The three textures should blend like shown in this example: How can I achieve that in DirectX (preferably in directx9)? A link or example code would be nice. Update: My rendering method looks like this and I still think I am doing it wrong, because the sprite only shows the last texture (nothing is rendered transparent or blended): void D3DTester::render() { d3ddevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0); d3ddevice->BeginScene(); d3ddevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); d3ddevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); d3ddevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); LPD3DXSPRITE sprite=NULL; HRESULT hres = D3DXCreateSprite(d3ddevice, &sprite); if(hres != S_OK) { throw std::exception(); } sprite->Begin(D3DXSPRITE_ALPHABLEND); std::vector<LPDIRECT3DTEXTURE9>::iterator it; for ( it=textures.begin() ; it < textures.end(); it++ ) { sprite->Draw(*it, NULL, NULL, NULL, 0xFFFFFFFF); } sprite->End(); d3ddevice->EndScene(); d3ddevice->Present(NULL, NULL, NULL, NULL); } The resulting image looks like this: But I need it to look like this instead: Update2: I figured out that I have to SetRenderState after I use sprite->Begin(D3DXSPRITE_ALPHABLEND); thanks to the hint by Josh Petrie. However, by using this: sprite->Begin(D3DXSPRITE_ALPHABLEND); d3ddevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); d3ddevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); d3ddevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); std::vector<LPDIRECT3DTEXTURE9>::iterator it; for ( it=textures.begin() ; it < textures.end(); it++ ) { sprite->Draw(*it, NULL, NULL, NULL, 0xFFFFFFFF); } sprite->End(); The sprites colors are becoming transparent towards the background scene e.g.: if I use d3ddevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,100,21), 1.0f, 0); the result looks like: Is there any way to avoid that? I would like the sprites be transparent to each other but to be still solid to the background. Update3: After having sombody explained to me, how to do what @LaurentCouvidou and @JoshPetrie suggested, I have a working solution and therfore accept the answer: d3ddevice->BeginScene(); D3DCOLOR white = D3DCOLOR_RGBA((UINT)255, (UINT)255, (UINT)255, 255); D3DCOLOR black = D3DCOLOR_RGBA((UINT)0, (UINT)0, (UINT)0, 255); sprite->Begin(D3DXSPRITE_ALPHABLEND); sprite->Draw(pTextureRed, NULL, NULL, NULL, black); sprite->Draw(pTextureGreen, NULL, NULL, NULL, black); sprite->Draw(pTextureBlue, NULL, NULL, NULL, black); sprite->End(); sprite->Begin(D3DXSPRITE_ALPHABLEND); d3ddevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); d3ddevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); d3ddevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); d3ddevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); sprite->Draw(pTextureRed, NULL, NULL, NULL, white); sprite->Draw(pTextureGreen, NULL, NULL, NULL, white); sprite->Draw(pTextureBlue, NULL, NULL, NULL, white); sprite->End(); d3ddevice->EndScene(); d3ddevice->Present(NULL, NULL, NULL, NULL);

    Read the article

  • SFML fail to load image as texture

    - by zyeek
    I have come to a problem with the code below ... Using SFML 2.0 #include <SFML/Graphics.hpp> #include <iostream> #include <list> int main() { float speed = 5.0f; // create the window sf::RenderWindow window(sf::VideoMode(sf::VideoMode::getDesktopMode().height - 300, 800), "Bricks"); // Set game window position on the screen window.setPosition( sf::Vector2i(sf::VideoMode::getDesktopMode().width/4 + sf::VideoMode::getDesktopMode().width/16 , 0) ); // Allow library to accept repeatitive key presses (i.e. holding key) window.setKeyRepeatEnabled(true); // Hide mouse cursor //window.setMouseCursorVisible(false); // Limit 30 frames per sec; the minimum for all games window.setFramerateLimit(30); sf::Texture texture; if (!texture.loadFromFile("tile.png", sf::IntRect(0, 0, 125, 32))) { std::cout<<"Could not load image\n"; return -1; } // Empty list of sprites std::list<sf::Sprite> spriteContainer; bool gameFocus = true; // run the program as long as the window is open while (window.isOpen()) { sf::Vector2i mousePos = sf::Mouse::getPosition(window); // check all the window's events that were triggered since the last iteration of the loop sf::Event event; while (window.pollEvent(event)) { float offsetX = 0.0f, offsetY = 0.0f; if(event.type == sf::Event::GainedFocus) gameFocus = !gameFocus; else if(event.type == sf::Event::LostFocus) gameFocus = !gameFocus; if(event.type == sf::Event::KeyPressed) { if (event.key.code == sf::Keyboard::Space) { if(gameFocus) { // Create sprite and add features before putting it into container sf::Sprite sprite(texture); sprite.scale(.9f,.7f); sf::Vector2u textSize = texture.getSize(); sprite.setPosition(sf::Vector2f(mousePos.x-textSize.x/2.0f, mousePos.y - textSize.y/2.0f)); spriteContainer.push_front(sprite); } } if(event.key.code == sf::Keyboard::P) std::cout << spriteContainer.size() << std::endl; if( event.key.code == sf::Keyboard::W ) offsetY -= speed; if( event.key.code == sf::Keyboard::A ) offsetX -= speed; if( event.key.code == sf::Keyboard::S ) offsetY += speed; if( event.key.code == sf::Keyboard::D ) offsetX += speed; } // "close requested" event: we close the window if (event.type == sf::Event::Closed || event.key.code == sf::Keyboard::Escape) window.close(); // Move all sprites synchronously for (std::list<sf::Sprite>::iterator sprite = spriteContainer.begin(); sprite != spriteContainer.end(); ++sprite) sprite->move(offsetX, offsetY); //sprite.move(offsetX,offsetY); } // clear the window with black color window.clear(sf::Color::Black); // draw everything here... // window.draw(...); // Draw all sprites in the container for (std::list<sf::Sprite>::iterator sprite = spriteContainer.begin(); sprite != spriteContainer.end(); ++sprite) window.draw(*sprite); // end the current frame window.display(); } return 0; } A couple weeks ago it worked flawlessly to my expectation, but now that I come back to it and I am having problems importing the image as a texture "tile.png". I don't understand why this is evening happening and the only message I get via the terminal is "Cannot load image ..." then a bunch of random characters. My libraries are for sure working, but now I am not sure why the image is not loading. My image is in the same directory as with my .h and .cpp files. This is an irritating problem that keep coming up for some reason and is always a problem to fix it. I import my libraries via my own directory "locals" which contain many APIs, but I specifically get SFML, and done appropriately as I am able to open a window and many other stuff.

    Read the article

  • Achieve Named Criteria with multiple tables in EJB Data control

    - by Deepak Siddappa
    In EJB create a named criteria using sparse xml and in named criteria wizard, only attributes related to the that particular entities will be displayed.  So here we can filter results only on particular entity bean. Take a scenario where we need to create Named Criteria based on multiple tables using EJB. In BC4J we can achieve this by creating view object based on multiple tables. So in this article, we will try to achieve named criteria based on multiple tables using EJB.Implementation StepsCreate Java EE Web Application with entity based on Departments and Employees, then create a session bean and data control for the session bean.Create a Java Bean, name as CustomBean and add below code to the file. Here in java bean from both Departments and Employees tables three fields are taken. public class CustomBean { private BigDecimal departmentId; private String departmentName; private BigDecimal locationId; private BigDecimal employeeId; private String firstName; private String lastName; public CustomBean() { super(); } public void setDepartmentId(BigDecimal departmentId) { this.departmentId = departmentId; } public BigDecimal getDepartmentId() { return departmentId; } public void setDepartmentName(String departmentName) { this.departmentName = departmentName; } public String getDepartmentName() { return departmentName; } public void setLocationId(BigDecimal locationId) { this.locationId = locationId; } public BigDecimal getLocationId() { return locationId; } public void setEmployeeId(BigDecimal employeeId) { this.employeeId = employeeId; } public BigDecimal getEmployeeId() { return employeeId; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getFirstName() { return firstName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getLastName() { return lastName; } } Open the sessionEJb file and add the below code to the session bean and expose the method in local/remote interface and generate a data control for that. Note:- Here in the below code "em" is a EntityManager. public List<CustomBean> getCustomBeanFindAll() { String queryString = "select d.department_id, d.department_name, d.location_id, e.employee_id, e.first_name, e.last_name from departments d, employees e\n" + "where e.department_id = d.department_id"; Query genericSearchQuery = em.createNativeQuery(queryString, "CustomQuery"); List resultList = genericSearchQuery.getResultList(); Iterator resultListIterator = resultList.iterator(); List<CustomBean> customList = new ArrayList(); while (resultListIterator.hasNext()) { Object col[] = (Object[])resultListIterator.next(); CustomBean custom = new CustomBean(); custom.setDepartmentId((BigDecimal)col[0]); custom.setDepartmentName((String)col[1]); custom.setLocationId((BigDecimal)col[2]); custom.setEmployeeId((BigDecimal)col[3]); custom.setFirstName((String)col[4]); custom.setLastName((String)col[5]); customList.add(custom); } return customList; } Open the DataControls.dcx file and create sparse xml for customBean. In sparse xml navigate to Named criteria tab -> Bind Variable section, create two binding variables deptId,fName. In sparse xml navigate to Named criteria tab ->Named criteria, create a named criteria and map the query attributes to the bind variables. In the ViewController create a file jspx page, from data control palette drop customBeanFindAll->Named Criteria->CustomBeanCriteria->Query as ADF Query Panel with Table. Run the jspx page and enter values in search form with departmentId as 50 and firstName as "M". Named criteria will filter the query of a data source and display the result like below.

    Read the article

  • How to display ppt file in Android views using Docx4j

    - by Ganesh
    I am working on Android and using docx4j to view the docx,pptx and xlsx files into my application. I am unable to view the ppt files . I am getting compile time error at SvgExporter class. which is not there in docx4j library. Can any one help me out to get the SvgExporter class library and build my application and get the Svghtml to load on webview for ppt files. my code is as follows. String inputfilepath = System.getProperty("user.dir") + "/sample-docs/pptx/pptx-basic.xml"; // Where to save images SvgExporter.setImageDirPath(System.getProperty("user.dir") + "/sample-docs/pptx/"); PresentationMLPackage presentationMLPackage = (PresentationMLPackage)PresentationMLPackage.load(new java.io.File(inputfilepath)); // TODO - render slides in document order! Iterator partIterator = presentationMLPackage.getParts().getParts().entrySet().iterator(); while (partIterator.hasNext()) { Map.Entry pairs = (Map.Entry)partIterator.next(); Part p = (Part)pairs.getValue(); if (p instanceof SlidePart) { System.out.println( SvgExporter.svg(presentationMLPackage, (SlidePart)p) ); } } // NB: file suffix must end with .xhtml in order to see the SVG in a browser }

    Read the article

  • EclEmma JAVA Code coverage - Unable to coverage service layer of RESTful Webservice

    - by Radhika
    I am using EMMA eclipse plugin to generate code coverage reports. My application is a RESTFul webservice. Junits are written such that a client is created for the webservice and invoked with various inputs. However EMMA shows 0% coverage for the source folder. The test folder alone is covered. The application server(jetty server) is started using a main method. Report: Element Coverage Covered Instructions Total Instructions MyRestFulService 13.6% 900 11846 src 0.5% 49 10412 test 98% 1021 1434 Junit Test method: @Test public final void testAddFlow() throws Exception { Client c = Client.create(); WebResource webResource = c.resource(BASE_URI); // Sample files for Add String xhtmlDocument = null; Iterator iter = mapOfAddFiles.entrySet().iterator(); while (iter.hasNext()) { Map.Entry pairs = (Map.Entry) iter.next(); try { document = helper.readFile(requestPath + pairs.getKey()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } /* POST */ MultiPart multiPart = new MultiPart(); multiPart.bodyPart(.... ........... ClientResponse response = webResource.path("/add").type( MEDIATYPE_MULTIPART_MIXED).post(ClientResponse.class, multiPart); assertEquals("TESTING ADD FOR >>>>>>> " + pairs.getKey(), Status.OK, response.getClientResponseStatus()); } } } Invoked service method: @POST @Path("add") @Consumes("multipart/mixed") public Response add(MultiPart multiPart) throws Exception { Status status = null; List<BodyPart> bodyParts = null; bodyParts = multiPart.getBodyParts(); status = //call to business layer return Response.ok(status).build(); }

    Read the article

  • Android - Launch Intent within ExpandableListView

    - by Ryan
    Hello, I'm trying to figure out if it is possible to launch an intent within an ExpandableListView. Basically one of the "Groups" is Phone Number and it's child is the number. I want the user to be able to click it and have it automatically call that number. Is this possible? How? Here is my code to populate the ExpandableListView using a Map called "data". ExpandableListView myList = (ExpandableListView) findViewById(R.id.myList); //ExpandableListAdapter adapter = new MyExpandableListAdapter(data); List<Map<String, String>> groupData = new ArrayList<Map<String, String>>(); List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>(); Iterator it = data.entrySet().iterator(); while (it.hasNext()) { //Get the key name and value for it Map.Entry pair = (Map.Entry)it.next(); String keyName = (String) pair.getKey(); String value = pair.getValue().toString(); //Add the parents -- aka main categories Map<String, String> curGroupMap = new HashMap<String, String>(); groupData.add(curGroupMap); curGroupMap.put("NAME", keyName); //Add the child data List<Map<String, String>> children = new ArrayList<Map<String, String>>(); Map<String, String> curChildMap = new HashMap<String, String>(); children.add(curChildMap); curChildMap.put("NAME", value); childData.add(children); } // Set up our adapter mAdapter = new SimpleExpandableListAdapter( mContext, groupData, R.layout.exp_list_parent, new String[] { "NAME", "IS_EVEN" }, new int[] { R.id.rowText1, R.id.rowText2 }, childData, R.layout.exp_list_child, new String[] { "NAME", "IS_EVEN" }, new int[] { R.id.rowText3, R.id.rowText4} ); myList.setAdapter(mAdapter);

    Read the article

  • Calculating skew of text OpenCV

    - by Nick
    I am trying to calculate the skew of text in an image so I can correct it for the best OCR results. Currently this is the function I am using: double compute_skew(Mat &img) { // Binarize cv::threshold(img, img, 225, 255, cv::THRESH_BINARY); // Invert colors cv::bitwise_not(img, img); cv::Mat element = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(5, 3)); cv::erode(img, img, element); std::vector<cv::Point> points; cv::Mat_<uchar>::iterator it = img.begin<uchar>(); cv::Mat_<uchar>::iterator end = img.end<uchar>(); for (; it != end; ++it) if (*it) points.push_back(it.pos()); cv::RotatedRect box = cv::minAreaRect(cv::Mat(points)); double angle = box.angle; if (angle < -45.) angle += 90.; cv::Point2f vertices[4]; box.points(vertices); for(int i = 0; i < 4; ++i) cv::line(img, vertices[i], vertices[(i + 1) % 4], cv::Scalar(255, 0, 0), 1, CV_AA); return angle; } When I look at then angle in debug I get 0.000000 However when I give it this image I get proper results of a skew of about 16 degrees: How can I properly detect the skew in the first image?

    Read the article

  • Bouncycastle encryption algorithms not provided

    - by David Read
    I'm trying to use BouncyCastle with android to implement ECDH and EL Gamal. I've added the bouncycastle jar file (bcprov-jdk16-144.jar) and written some code that works with my computers jvm however when I try and port it to my android application it throws: java.security.NoSuchAlgorithmException: KeyPairGenerator ECDH implementation not found A sample of the code is: Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); java.security.KeyPairGenerator keyGen = org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator.getInstance("ECDH", "BC"); ECGenParameterSpec ecSpec = new ECGenParameterSpec("prime192v1"); keyGen.initialize(ecSpec, SecureRandom.getInstance("SHA1PRNG")); KeyPair pair = keyGen.generateKeyPair(); PublicKey pubk = pair.getPublic(); PrivateKey prik = pair.getPrivate(); I then wrote a simple program to see what encryption algorithms are available and ran it on my android emulator and on my computers jvm the code was: Set<Provider.Service> rar = new org.bouncycastle.jce.provider.BouncyCastleProvider().getServices(); Iterator<Provider.Service> ir = rar.iterator(); while(ir.hasNext()) System.out.println(ir.next().getAlgorithm()); On android I do not get any of the EC algorithms while ran normally on my computer it's fine. I'm also getting the following two errors when compiling for a lot of the bouncy castle classes: 01-07 17:17:42.548: INFO/dalvikvm(1054): DexOpt: not resolving ambiguous class 'Lorg/bouncycastle/asn1/ASN1Encodable;' 01-07 17:17:42.548: DEBUG/dalvikvm(1054): DexOpt: not verifying 'Lorg/bouncycastle/asn1/ess/OtherSigningCertificate;': multiple definitions What am I doing wrong?

    Read the article

  • Selector and Iterating Through a Table Within a Div

    - by GregH
    I have been working on this and cannot get this iterator to work. I have the following HTML and am trying to iterate through all rows (except the first row) and extract the values in cells (td) 2 and 3 : <div id="statsId"> <table width="220" cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <td width="65"/> <td width="90"/> <td width="65"/> </tr> <tr style="font-weight: bold;"> <td align="left">$1.00</td> <td> <a href="#">UserID1</a> </td> <td>Single</td> </tr> <tr> <td align="left">$6.99</td> <td> <a href="#">UserID2</a> </td> <td>Multiple</td> </tr> <tr>... .....(snip) I tried the following iterator to iterate through all except the first row of the table that is a child of "div#statsID" and get the values of the 2nd and 3rd cells (in the example, the first extracted cells would have values of "UserID1" and "Single"), but it doesn't work. $('div#statsId > table tr:not(:nth-child(1))').each(function(i, ele) { var secondCol = $('td:nth-child(2)', ele).innerHTML var thirdCol= $('td:nth-child(3)', ele).text() ..... }); Any suggestions on how to specify and iterate through the rows (except the first) of a table that is a child of a div would be appreciated.

    Read the article

  • Jsf RichFaces autocomplete : get the String for autocomplete- method()

    - by JavaNullPointer
    Part of my xhmtl-Page: <rich:autocomplete autocompleteMethod="#{autocompletMit.searchbyName()}" mode="cachedAjax" fetchValue="#{controller.mitarbeiter.mitarbeiterName}" autocompleteList="#{autocompletMit.autocompleteList}" minChars="1" autofill="true" var="it" > <h:outputText value="#{it.mitarbeiterName}" style="font-weight:bold"/> </rich:autocomplete> Bean for my Autocomplete: @ManagedBean(name = "autocompletMit") @RequestScoped public class AutoCompleteMitarbeiter implements Serializable { @EJB private Transaktionssteuerung transakt; private List<String> autocompleteList = new ArrayList<String>(); String nameSearch; public List<String> searchbyName(Object o) { String test = (String) o; //always get here a NullPointerException List<Mitarbeiter> alleMitarbeiter = transakt.alleMitarbeiter(); for (Iterator<Mitarbeiter> it = alleMitarbeiter.iterator(); it.hasNext();) { if (it.next().getMitarbeiterName().startsWith(test)) { autocompleteList.add(it.next().getMitarbeiterName()); } } return autocompleteList; } I always get a NullPointerException for String test = (String) o; I dont know how to get the StringInput correctly from </rich:autocomplete>-Input....

    Read the article

  • Parsing string, with Boost Spirit 2, to fill data in user defined struct

    - by Surya
    I'm using Boost.Spirit which was distributed with Boost-1.42.0 with VS2005. My problem is like this. I've this string which was delimted with commas. The first 3 fields of it are strings and rest are numbers. like this. String1,String2,String3,12.0,12.1,13.0,13.1,12.4 My rule is like this qi::rule<string::iterator, qi::skip_type> stringrule = *(char_ - ',') qi::rule<string::iterator, qi::skip_type> myrule= repeat(3)[*(char_ - ',') >> ','] >> (double_ % ',') ; I'm trying to store the data in a structure like this. struct MyStruct { vector<string> stringVector ; vector<double> doubleVector ; } ; MyStruct var ; I've wrapped it in BOOST_FUSION_ADAPT_STRUCTURE to use it with spirit. BOOST_FUSION_ADAPT_STRUCT (MyStruct, (vector<string>, stringVector) (vector<double>, doubleVector)) My parse function parses the line and returns true and after qi::phrase_parse (iterBegin, iterEnd, myrule, boost::spirit::ascii::space, var) ; I'm expecting var.stringVector and var.doubleVector are properly filled. but it is not the case. What is going wrong ? Thanks in advance, Surya

    Read the article

  • Compile error on inheritance of generic inner class extending with bounds

    - by Arne Burmeister
    I have a problem when compiling a generic class with an inner class. The class extends a generic class, the inner class also. Here the interface implemented: public interface IndexIterator<Element> extends Iterator<Element> { ... } The generic super class: public abstract class CompoundCollection<Element, Part extends Collection<Element>> implements Collection<Element> { ... protected class CompoundIterator<Iter extends Iterator<Element>> extends ImmutableIterator<Element> { ... } } The generic subclass with the compiler error: public class CompoundList<Element> extends CompoundCollection<Element, List<Element>> implements List<Element> { ... private class CompoundIndexIterator extends CompoundIterator<IndexIterator<Element>> implements IndexIterator<Element> { ... } } The error is: type parameter diergo.collect.IndexIterator<Element> is not within its bound extends CompoundIterator<IndexIterator<Element>> ^ What is wrong? The code compiles with eclipse, but bot with java 5 compiler (I use ant with java 5 on a mac and eclipse 3.5). No, I cannot convert it to a static inner class.

    Read the article

  • Struts2 + jQuery Autocompletion (Solved, with DOJO :) )

    - by Luigi 1982
    I used the jQuery autocompletion for my Struts2 application. Pratically, my action made a list of strings that jQuery use. This is the script: $().ready(function() { $("#tag").autocomplete("/myAction/Action", { multiple : true, autoFill : true, minChars:1 }); }); During typing appear the box with the suggestions. The problem is that the box render another value, exactly render the code of my JSP ( links to CSS for the autocomplete plug-in). How can I solve this? This is my JSP: <html> <head> <script src="<%=request.getContextPath()%>/scripts/jquery-latest.js"></script> <link rel="stylesheet" href="<%=request.getContextPath()%>/scripts/main.css" type="text/css" /> <link rel="stylesheet" href="<%=request.getContextPath()%>/scripts/jquery.autocomplete.css" type="text/css" /> <script type="text/javascript" src="<%=request.getContextPath()%>scripts/jquery.bgiframe.min.js"></script> <script type="text/javascript" src="/<%=request.getContextPath()%>/query.dimensions.js"></script> <script type="text/javascript" src="<%=request.getContextPath()%>/scripts/jquery.autocomplete.js"></script> <script type="text/javascript"> $().ready(function() { $("#tag").autocomplete("/myAction/Action", { multiple : true, autoFill : true, minChars:1 }); }); </script> </head> <body> <s:form action="Action" theme="simple"> <s:iterator value="elencoMateriali" var="asd"> <s:property value="#asd" escape="false"/> </s:iterator> <s:textfield id="tag" name="tagField" label="tag" /> </s:form> </body>

    Read the article

  • How to keep only duplicates efficiently?

    - by Marc Eaddy
    Given an STL vector, I'd like an algorithm that outputs only the duplicates in sorted order, e.g., INPUT : { 4, 4, 1, 2, 3, 2, 3 } OUTPUT: { 2, 3, 4 } The algorithm is trivial, but the goal is to make it as efficient as std::unique(). My naive implementation modifies the container in-place: My naive implementation: void keep_duplicates(vector<int>* pv) { // Sort (in-place) so we can find duplicates in linear time sort(pv->begin(), pv->end()); vector<int>::iterator it_start = pv->begin(); while (it_start != pv->end()) { size_t nKeep = 0; // Find the next different element vector<int>::iterator it_stop = it_start + 1; while (it_stop != pv->end() && *it_start == *it_stop) { nKeep = 1; // This gets set redundantly ++it_stop; } // If the element is a duplicate, keep only the first one (nKeep=1). // Otherwise, the element is not duplicated so erase it (nKeep=0). it_start = pv->erase(it_start + nKeep, it_stop); } } If you can make this more efficient, elegant, or general, please let me know. For example, a custom sorting algorithm, or copy elements in the 2nd loop to eliminate the erase() call.

    Read the article

  • First-chance exception at std::set dectructor

    - by bartek
    Hi, I have a strange exception at my class destructor: First-chance exception reading location 0x00000 class DispLst{ // For fast instance existance test std::set< std::string > instances; [...] DispLst::~DispLst(){ this->clean(); DeleteCriticalSection( &instancesGuard ); } <---- here instances destructor raises exception Call stack: X.exe!std::_Tree,std::allocator ,std::less,std::allocator ,std::allocator,std::allocator ,0 ::begin() Line 556 + 0xc bytes C++ X.exe!std::_Tree,std::allocator ,std::less,std::allocator ,std::allocator,std::allocator ,0 ::_Tidy() Line 1421 + 0x64 bytes C++ X.exe!std::_Tree,std::allocator ,std::less,std::allocator ,std::allocator,std::allocator ,0 ::~_Tree,std::allocator ,std::less,std::allocator ,std::allocator,std::allocator ,0 () Line 541 C++ X.exe!std::set,std::allocator ,std::less,std::allocator ,std::allocator,std::allocator ::~set,std::allocator ,std::less,std::allocator ,std::allocator,std::allocator () + 0x2b bytes C++ X.exe!DispLst::~DispLst() Line 82 + 0xf bytes C++ The exact place of error in xtree: void _Tidy() { // free all storage erase(begin(), end()); <------------------- HERE this->_Alptr.destroy(&_Left(_Myhead)); this->_Alptr.destroy(&_Parent(_Myhead)); this->_Alptr.destroy(&_Right(_Myhead)); this->_Alnod.deallocate(_Myhead, 1); _Myhead = 0, _Mysize = 0; } iterator begin() { // return iterator for beginning of mutable sequence return (_TREE_ITERATOR(_Lmost())); <---------------- HERE } What is going on ? I'm using Visual Studio 2008.

    Read the article

  • OSX / Kernel extensions: problem locating a driver (that extends IOSCSIPeripheralDeviceType00)

    - by LG
    Hi, I'm implementing a driver that extends IOSCSIPeripheralDeviceType00 as I need to send custom SCSI commands to a device. I'm following the VendorSpecificType00 and SimpleUserClient examples and http://wagerlabs.com/writing-a-mac-osx-usb-device-driver-that-impl as an example. I built my kernel extension and it loads fine with kextload and it shows up in kextstat. The problem is that I can't locate it in my user space code. Here's the important (I think) part of: my driver code: #define super IOSCSIPeripheralDeviceType00 OSDefineMetaClassAndStructors(com_mycompany_driver_Foo, IOSCSIPeripheralDeviceType00) my user client code: #define super IOUserClient OSDefineMetaClassAndStructors(com_mycompany_driver_FooUserClient, IOUserClient) the plist: CFBundleIdentifier -> com.mycompany.driver.Foo IOCLass -> com_mycompany_driver_Foo IOUserClientClass -> com_mycompany_driver_FooUserClient IOProviderClass -> IOSCSIPeripheralDeviceNub Here's how I try to locate the driver in my user space code (similar to SimpleUserClient): dictRef = IOServiceMatching("com_mycompany_driver_Foo"); kernResult = IOServiceGetMatchingServices(kIOMasterPortDefault, dictRef, &iterator); When I execute the code, iterator is 0. I noticed that in the VendorSpecificType00 code, the localization of the driver is done differently: dictRef = IOServiceMatching("IOBlockStorageServices"); kr = IOServiceGetMatchingServices(kIOMasterPortDefault, dictRef, &iter); while ((service = IOIteratorNext(iter))) { io_registry_entry_t parent; kr = IORegistryEntryGetParentEntry(service, kIOServicePlane, &parent); ... // We're only interested in the parent object if it's our driver class. if (IOObjectConformsTo(parent, "com_apple_dts_driver_VendorSpecificType00")) { I tried doing that but it didn't work either. Thanks for reading and your help, -L

    Read the article

  • Jquery validations on form with no fields

    - by jcovert
    I have a table (in a form) populated with radio buttons (with a button for each value in a collection). If the collection is empty, nothing shows up in the table (which is fine). (I'm using Struts2) My trouble comes when validating that the user has selected one of these radio buttons when the submit button is clicked. I'm using JQUERY validations, and it works quite well UNLESS there are no radio buttons to select (collection is empty). $('#startProcessForm').validate({ rules: { selectedProcess: { required: true } }, messages: { selectedProcess: "Please select a process to start." } }); If the list IS empty, then there are no fields (radio button or otherwise) named "selectedProcess". So my question is this: How can I make "selectedProcess" exist AND fail the 'required:true' validation if there's nothing in the collection? I was thinking I could create an empty tag of the same name (selectedProcess) if the collection is empty? Here's what I'd guess would work but doesn't seem to: <s:if test="processes != null && !processes.isEmpty()"> <s:iterator value="processes" status="processesStatus"> <tr> <td><s:radio name="selectedProcess" list="{name}"></s:radio></td> </tr> </s:iterator> </s:if> <s:else> <tr> <td><a name="selectedProcess"></a></td> </tr> </s:else> Thanks!

    Read the article

  • Mocking inter-method dependencies

    - by Zecrates
    I've recently started using mock objects in my tests, but I'm still very inexperienced with them and unsure of how to use them in some cases. At the moment I'm struggling with how to mock inter-method dependencies (calling method A has an effect on the results of method B), and whether it should even be mocked (in the sense of using a mocking framework) at all? Take for example a Java Iterator? It is easy enough to mock the next() call to return the correct values, but how do I mock hasNext(), which depends on how many times next() has been called? Currently I'm using a List.Iterator as I could find no way to properly mock one. Does Martin Fowler's distinction between mocks and stubs come into play here? Should I rather write my own IteratorMock? Also consider the following example. The method to be tested calls mockObject.setX() and later on mockObject.getX(). Is there any way that I can create such a mock (without writing my own) which will allow the returned value of getX to depend on what was passed to setX?

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >