Search Results

Search found 1519 results on 61 pages for 'chain'.

Page 31/61 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • Refactoring many nested ifs or chained if statements

    - by Icarus
    Hi, I have an object with large number of similar fields (like more than 10 of them) and I have to assign them values from an array of variable length. The solution would be either a huge nested bunch of ifs based on checking length of array each time and assigning each field OR a chain of ifs checking on whether the length is out of bounds and assigning each time after that check. Both seem to be repetitive. Is there a better solution ?

    Read the article

  • Getting a visitors Facebook page

    - by Mr Carl
    Hey guys, this is more of a question out of curiosity, but is it possible to get somebody's Facebook page after they have visited your site? Was thinking maybe a chain of lookup stuff could be used starting with an IP to eventually perhaps get a name and thus that person's Facebook page. I have also heard you can read somebody's web history, is this true?

    Read the article

  • how get xml responce using JAX-WS SOAP handler

    - by khris
    I have implemented web service: @WebServiceClient(//parameters//) @HandlerChain(file = "handlers.xml") public class MyWebServiceImpl {...} Also I have implemented ObjectFactory with list of classes for creating my requests and responses. For Example class Test. I need to get xml of response. I try to use JAX-WS SOAP handler, so I add this @HandlerChain(file = "handlers.xml") anotation. My handlers.xml looks like: <?xml version="1.0" encoding="UTF-8"?> <handler-chains xmlns="http://java.sun.com/xml/ns/javaee"> <handler-chain> <handler> <handler-class>java.com.db.crds.ws.service.LoggingHandler</handler-class> </handler> </handler-chain> </handler-chains> My LoggingHandler class is: import java.io.PrintWriter; import java.util.Set; import javax.xml.namespace.QName; import javax.xml.soap.SOAPMessage; import javax.xml.ws.handler.MessageContext; import javax.xml.ws.handler.soap.SOAPMessageContext; public class LoggingHandler implements javax.xml.ws.handler.soap.SOAPHandler<SOAPMessageContext> { public void close(MessageContext messagecontext) { } public Set<QName> getHeaders() { return null; } public boolean handleFault(SOAPMessageContext messagecontext) { return true; } public boolean handleMessage(SOAPMessageContext smc) { Boolean outboundProperty = (Boolean) smc.get (MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty.booleanValue()) { System.out.println("\nOutbound message:"); } else { System.out.println("\nInbound message:"); } SOAPMessage message = smc.getMessage(); try { PrintWriter writer = new PrintWriter("soap_responce" + System.currentTimeMillis(), "UTF-8"); writer.println(message); writer.close(); message.writeTo(System.out); System.out.println(""); // just to add a newline } catch (Exception e) { System.out.println("Exception in handler: " + e); } return outboundProperty; } } I have test class which creates request, here are part of code: MyWebServiceImpl impl = new MyWebServiceImpl(url, qName); ws = impl.getMyWebServicePort(); Test req = new Test(); I suppose to get xml response in file "soap_responce" + System.currentTimeMillis(). But such file isn't even created. Please suggest how to get xml response, I'm new to web services and may do something wrong. Thanks

    Read the article

  • If-else-if versus map

    - by perezvon
    Hi, Suppose I have such an if/else-if chain: if( x.GetId() == 1 ) { } else if( x.GetId() == 2 ) { } // ... 50 more else if statements What I wonder is, if I keep a map, will it be any better in terms of performance? (assuming keys are integers)

    Read the article

  • Writing csv header removes data from numpy array written below

    - by user338095
    I'm trying to export data to a csv file. It should contain a header (from datastack) and restacked arrays with my data (from datastack). One line in datastack has the same length as dataset. The code below works but it removes parts of the first line from datastack. Any ideas why that could be? s = ','.join(itertools.chain(dataset)) + '\n' newfile = 'export.csv' f = open(newfile,'w') f.write(s) numpy.savetxt(newfile, (numpy.transpose(datastack)), delimiter=', ') f.close()

    Read the article

  • Resources for Windows Phone 7 development

    - by geocoin
    Windows Phone 7 has just been unveiled and right now there is no publicly available information to non-privileged developers/partners. MS are announcing all details of the development chain at the Mix10 conference. So until then this could be a good starting point/collection of online resources as they appear EDIT: I've added the speculation tag so we can also accumulate speculation. Please mark speculative posts as such. once firm details are announced we can confirm or delete them

    Read the article

  • Httpsession with Spring 3 MVC

    - by vipul12389
    I want to use httpsession in Spring 3 MVC..i have searched all the web and got this solution..at http://forum.springsource.org/showthread.php?98850-Adding-to-stuff-to-the-session-while-using-ResponseBody Basically, My application auto authenticates user by getting winId and authorizes through LDAP..(Its a intranet site) Here is the flow of the application, 1. User enters Aplication url (http://localhost:8082/eIA_Mock_5) it has a welcome page (index.jsp) Index.jsp gets winId through jQuery and hits login.html (through Ajax) and passes windowsId login.html (Controller) authenticates through LDAP and gives back 'Valid' String as a response javascript, upon getting the correct response, redirects/loads welcome page i.e. goes to localhost:8082/eIA_Mock_5/welcome.html Now, i have filter associated with it..which checks for is session valid for each incoming request..Now the problem is even though i set data on to httpsession, yet the filter or any other controller fails to get the data through session as a result it doesnt proceeds further.. here is the code..and could you suggest what is wrong actually ?? Home_Controller.java @Controller public class Home_Controller { public static Log logger = LogFactory.getLog(Home_Controller.class); @RequestMapping(value={"/welcome"}) public ModelAndView loadWelcomePage(HttpServletRequest request,HttpServletResponse response) { ModelAndView mdv = new ModelAndView(); try{ /*HttpSession session = request.getSession(); UserMasterBean userBean = (UserMasterBean)session.getAttribute("userBean"); String userName=userBean.getWindowsId(); if(userName==null || userName.equalsIgnoreCase("")) { mdv.setViewName("homePage"); System.out.println("Unable to authenticate user "); logger.debug("Unable to authenticate user "); } else { System.out.println("Welcome User "+userName); logger.debug("Welcome User "+userName); */ mdv.setViewName("homePage"); /*}*/ } catch(Exception e){ logger.debug("inside authenticateUser ",e); e.printStackTrace(); } return mdv; } @RequestMapping(value = "/login", method = RequestMethod.GET) public @ResponseBody String authenticateUser(@RequestParam String userName,HttpSession session) { logger.debug("inside authenticateUser"); String returnResponse=new String(); try{ logger.debug("userName for Authentication "+userName); System.out.println("userName for Authentication "+userName); //HttpSession session = request.getSession(); if(userName==null || userName.trim().equalsIgnoreCase("")) returnResponse="Invalid"; else { System.out.println("uname "+userName); String ldapResponse = LDAPConnectUtil.isValidActiveDirectoryUser(userName, ""); if(ldapResponse.equalsIgnoreCase("true")) { returnResponse="Valid"; System.out.println(userName+" Authenticated"); logger.debug(userName+" Authenticated"); UserMasterBean userBean = new UserMasterBean(); userBean.setWindowsId(userName); //if(session.getAttribute("userBean")==null) session.setAttribute("userBean", userBean); } else { returnResponse="Invalid"; //session.setAttribute("userBean", null); System.out.println("Unable to Authenticate the user through Ldap"); logger.debug("Unable to Authenticate the user through Ldap"); } System.out.println("ldapResponse "+ldapResponse); logger.debug("ldapResponse "+ldapResponse); System.out.println("returnResponse "+returnResponse); } UserMasterBean u = (UserMasterBean)session.getAttribute("userBean"); System.out.println("winId "+u.getWindowsId()); } catch(Exception e){ e.printStackTrace(); logger.debug("Exception in authenticateUser ",e); } return returnResponse; } Filter public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) { System.out.println("in PageFilter"); boolean flag = false; HttpServletRequest objHttpServletRequest = (HttpServletRequest)request; HttpServletResponse objHttpServletResponse = (HttpServletResponse)response; HttpSession session = objHttpServletRequest.getSession(); String contextPath = objHttpServletRequest.getContextPath(); String servletPath = objHttpServletRequest.getSession().getServletContext().getRealPath(objHttpServletRequest.getServletPath()); logger.debug("contextPath :" + contextPath); logger.debug("servletPath :" + servletPath); System.out.println("in PageFilter, contextPath :" + contextPath); System.out.println("in PageFilter, servletPath :" + servletPath); if (servletPath.endsWith("\\") || servletPath.endsWith("/") || servletPath.indexOf("css") > 0 || servletPath.indexOf("jsp") > 0 || servletPath.indexOf("images") > 0 || servletPath.indexOf("js") > 0 || servletPath.endsWith("index.jsp") || servletPath.indexOf("xls") > 0 || servletPath.indexOf("ini") > 0 || servletPath.indexOf("login.html") > 0 || /*servletPath.endsWith("welcome.html") ||*/ servletPath.endsWith("logout.do") ) { System.out.println("User is trying to access allowed pages like Login.jsp, errorPage.jsp, js, images, css"); logger.debug("User is trying to access allowed pages like Login.jsp, errorPage.jsp, js, images, css"); flag = true; } if (flag== false) { System.out.println("flag = false"); if(session.getAttribute("userBean") == null) System.out.println("yes session.userbean is null"); if ((session != null) && (session.getAttribute("userBean") != null)) { System.out.println("session!=null && session.getAttribute(userId)!=null"); logger.debug("IF Part"); UserMasterBean userBean = (UserMasterBean)session.getAttribute("userBean"); String windowsId = userBean.getWindowsId(); logger.debug("User Id " + windowsId + " allowed access"); System.out.println("User Id " + windowsId + " allowed access"); flag = true; } else { System.out.println("else .....session!=null && session.getAttribute(userId)!=null"); logger.debug("Else Part"); flag = false; } } if (flag == true) { try { System.out.println("before chain.doFilter(request, response)"); chain.doFilter(request, response); } catch (Exception e) { e.printStackTrace(); try { objHttpServletResponse.sendRedirect(contextPath + "/logout.do"); } catch (Exception ex) { ex.printStackTrace(); } } } else { try { System.out.println("before sendRedirect"); objHttpServletResponse.sendRedirect(contextPath + "/jsp/errorPage.jsp"); } catch (Exception ex) { ex.printStackTrace(); } } System.out.println("end of PageFilter"); } Index.jsp <script type="text/javascript"> //alert("inside s13"); var WinNetwork = new ActiveXObject("WScript.Network"); var userName=WinNetwork.UserName; alert(userName); $.ajax({ url : "login.html", data : "userName="+userName, success : function(result) { alert("result == "+result); if(result=="Valid") window.location = "http://10.160.118.200:8082/eIA_Mock_5/welcome.html"; } }); </script> web.xml has a filter entry with URL pattern as * I am using spring 3 mvc

    Read the article

  • How do i call a MouseDoubleClick event? WinForm

    - by acidzombie24
    In my MouseDoubleClick i may run into a case where i would like to call all the controls in a list with MouseDoubleClick. However i cant call MouseDoubleClick, only add/remove events to the chain. How do i call MouseDoubleClick/OnMouseDoubleClick? ATM i workaround the problem since i know the objects MouseDoubleClick function and i pass in the parameters myself calling that specific function. How do i call the event in the case i do not know what function is set to the control MouseDoubleClick

    Read the article

  • OpenSSL Ignore Self-signed certificate error

    - by Ramsey
    I'm writing a small program with the OpenSSL library that is suppose to establish a connection with an SSLv3 server. This server dispenses a self-signed certificate, which causes the handshake to fail with this message: "sslv3 alert handshake failure, self signed certificate in certificate chain." Is there a way I can force the connection to proceed? I've tried calling SSL_CTX_set_verify like so: SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); But it does not seem to change anything. Any suggestions?

    Read the article

  • JQuery input elements

    - by codeasp
    I need to get all input elements within a div and then attach event handlers, so that whenever values change it updates a hidden field. Children elements within the div might already contain event handlers, if so the attach should chain it. Any help is much appreciated.

    Read the article

  • JAVA: Can't get context parameters in Filter

    - by DaTval
    Hello, I have a filter and parameters in web.xml web.xml is like this: <filter> <description> </description> <display-name>AllClassFilter</display-name> <filter-name>AllClassFilter</filter-name> <filter-class>com.datval.homework.AllClassFilter</filter-class> <init-param> <param-name>DB_URL</param-name> <param-value>jdbc:derby:C:/Users/admin/workspace/homework03/homework/databases/StudentsDB;create=true</param-value> </init-param> <init-param> <param-name>DB_DIALECT</param-name> <param-value>org.hibernate.dialect.DerbyDialect</param-value> </init-param> <init-param> <param-name>DB_DRIVER</param-name> <param-value>org.apache.derby.jdbc.EmbeddedDriver</param-value> </init-param> </filter> mapping is working well. But I can't get this parameters in my filter. public void init(FilterConfig config) throws ServletException { // TODO Auto-generated method stub debugMessage = config.getInitParameter("debugMessage"); ctx = config.getServletContext(); } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // TODO Auto-generated method stub // place your code here ctx.log("Start - " + debugMessage); String myDbUrl = ctx.getInitParameter("DB_URL"); String DB_DIALECT = ctx.getInitParameter("DB_DIALECT"); String DB_DRIVER = ctx.getInitParameter("DB_DRIVER"); Map<String,String> pr = new HashMap<String,String>(); pr.put("hibernate.connection.url", myDbUrl); pr.put("hibernate.dialect", DB_DIALECT); pr.put("hibernate.connection.driver_class", DB_DRIVER); EntityManagerFactory emf = Persistence.createEntityManagerFactory("students",pr); EntityManager em = emf.createEntityManager(); request.setAttribute("em", em); chain.doFilter(request, response); em.close(); ctx.log("end - " + debugMessage); } I have checked and myDbUrl is null. What I'm doing wrong? Any idea? Sorry about code, I will change it later :)

    Read the article

  • How do i create my own Token?

    - by EugenA
    I use Rules-Module. I want to add 1 to a cck integer field on an action. Someone told me to create custom token doing this addition. So, I installed tokenSTARTER module. Now, how do i access the content profile (I load it in the rules chain) where needed cck field is in?

    Read the article

  • Bubbling up events . .

    - by oo
    I have multiple layers in an application and i find myself having to bubble up events to the GUI layer for doing status bar changes, etc . . I find myself having to write repeated coded where each layer simply subscribes to events from the lower layer and then in the call back simply raise an event up the chain. Is there a more efficient way of doing this?

    Read the article

  • Design pattern suggestion

    - by Avinash
    Following is the problem statement. There are n numbers of match strings, If event A occurs and then in certain period of time event B occurs then I do not raise alarm. but if B do not occurs then i have to raise alarm. There can be multiple chain of events which defines whether to raise alarm or not.

    Read the article

  • Please Describe Your Struggles with Minimizing Use of Global Variables

    - by MetaHyperBolic
    Most of the programs I write are relatively flowchartable processes, with a defined start and hoped-for end. The problems themselves can be complex but do not readily lean towards central use of objects and event-driven programming. Often, I am simply churning through great varied batches of text data to produce different text data. Only occasionally do I need to create a class: As an example, to track warnings, errors, and debugging message, I created a class (Problems) with one instantiation (myErr), which I believe to be an example of the Singleton design pattern. As a further factor, my colleagues are more old school (procedural) than I and are unacquainted with object-oriented programming, so I am loath to create things they could not puzzle through. And yet I hear, again and again, how even the Singleton design pattern is really an anti-pattern and ought to be avoided because Global Variables Are Bad. Minor functions need few arguments passed to them and have no need to know of configuration (unchanging) or program state (changing) -- I agree. However, the functions in the middle of the chain, which primarily control program flow, have a need for a large number of configuration variables and some program state variables. I believe passing a dozen or more arguments along to a function is a "solution," but hardly an attractive one. I could, of course, cram variables into a single hash/dict/associative array, but that seems like cheating. For instance, connecting to the Active Directory to make a new account, I need such configuration variables as an administrative username, password, a target OU, some default groups, a domain, etc. I would have to pass those arguments down through a variety of functions which would not even use them, merely shuffle them off down through a chain which would eventually lead to the function that actually needs them. I would at least declare the configuration variables to be constant, to protect them, but my language of choice these days (Python) provides no simple manner to do this, though recipes do exist as workarounds. Numerous Stack Overflow questions have hit on the why? of the badness and the requisite shunning, but do not often mention tips on living with this quasi-religious restriction. How have you resolved, or at least made peace with, the issue of global variables and program state? Where have you made compromises? What have your tricks been, aside from shoving around flocks of arguments to functions?

    Read the article

  • Is it possible to create a throttle function that can take in as parameters another function (that also has parameters), and the time delay

    - by Stan Quinn
    So I've already written a function that works (based on underscores throttle) for functions that don't take in a parameter, but I'd like to make it generic enough to pass in a function with a variable number of parameters. Here's what I have: (function () { var lastTime = new Date().getTime(); function foo() { var newTime = new Date().getTime(); var gap = newTime - lastTime; // Travels up scope chain to use parents lastTime. Function has access to variables declared in the same scope console.log('foo called, gap:' + gap); lastTime = newTime; // Updates lastTime //console.log(x); //x++; } var throttle = function(func, wait) { var result; var timeout = null; // flag updated through closure var previous = 0; // time last run updated through closure return function() { //func, wait, timeout, previous available through scope var now = new Date().getTime(); var remaining = wait - (now - previous); if (remaining <= 0) { clearTimeout(timeout); timeout = null; previous = now; result = func.apply(this, arguments); //func is available through closure } return result; }; }; document.addEventListener("scroll", throttle(foo, 1000)); //document.addEventListener("scroll", throttle(foo(5), 2000)); }()); But I'd like to modify foo to foo(x) and get this to work (function () { var lastTime = new Date().getTime(); function foo(x) { var newTime = new Date().getTime(); var gap = newTime - lastTime; // Travels up scope chain to use parents lastTime. Function has access to variables declared in the same scope console.log('foo called, gap:' + gap); lastTime = newTime; // Updates lastTime console.log(x); x++; } var throttle = function(func, wait) { var result; var timeout = null; // flag updated through closure var previous = 0; // time last run updated through closure return function() { //func, wait, timeout, previous available through scope var now = new Date().getTime(); var remaining = wait - (now - previous); if (remaining <= 0) { clearTimeout(timeout); timeout = null; previous = now; result = func.apply(this, arguments); //func is available through closure } return result; }; }; document.addEventListener("scroll", throttle(foo(5), 2000)); }());

    Read the article

  • What SQL query should I perform to get the result set expected?

    - by texai
    What SQL query should I perform to get the result set expected, giving the first element of the chain (2) as input data, or any of them ? table name: changes +----+---------------+---------------+ | id | new_record_id | old_record_id | +----+---------------+---------------+ | 1| 4| 2| | -- non relevant data -- | | 6| 7| 4| | -- non relevant data -- | | 11| 13| 7| | 12| 14| 13| | -- non relevant data -- | | 31| 20| 14| +----+---------------+---------------+ Result set expected: +--+ | 2| | 4| | 7| |13| |14| |20| +--+ I know I should consider change my data model, but: What if I couldn't? Thank you in advance!

    Read the article

  • Rendering UML diagrams from text files

    - by Per Ersson
    Is there any good tool or tool-chain that allows UML images in the .svg format to be created from a textual source file? The reason for this question is that I want to automate the generation of these images to avoid having to manually create and update this set of images.

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >