Search Results

Search found 11238 results on 450 pages for 'miserable variable'.

Page 34/450 | < Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >

  • What would be a better implementation of shared variable among subclass

    - by Churk
    So currently I have a spring unit testing application. And it requires me to get a session cookie from a foreign authentication source. Problem what that is, this authentication process is fairly expensive and time consuming, and I am trying to create a structure where I am authenticate once, by any subclass, and any subsequent subclass is created, it will reuse this session cookie without hitting the authentication process again. My problem right now is, the static cookie is null each time another subclass is created. And I been reading that using static as a global variable is a bad idea, but I couldn't think of another way to do this because of Spring framework setting things during run time and how I would set the cookie so that all other classes can use it. Another piece of information. The variable is being use, but is change able during run time. It is not a single user being signed in and used across the board. But more like a Sub1 would call login, and we have a cookie. Then multiple test will be using that login until SubX will come in and say, I am using different credential, so I need to login as something else. And repeats. Here is a outline of my code: public class Parent implements InitializingBean { protected static String BASE_URL; public static Cookie cookie; ... All default InitializingBean methods ... afterPropertiesSet() { cookie = // login process returns a cookie } } public class Sub1 extends Parent { @resource public String baseURL; @PostConstruct public void init() { // set parents with my baseURL; BASE_URL = baseURL; } public void doSomething() { // Do something with cookie, because it should have been set by parent class } } public class Sub2 extends Parent { @resource public String baseURL; @PostConstruct public void init() { // set parents with my baseURL; BASE_URL = baseURL; } public void doSomethingElse() { // Do something with cookie, because it should have been set by parent class } }

    Read the article

  • Moving Javascript object with all bounded events to other variable

    - by Saif Bechan
    Let's say I have an anchor tag, with some events. <a id="clickme" href="/endpoint">clickme</a> <a id="clickme2" href="/endpoint2">clickme2</a> Let's use jquery for simplicity: $('#clickme').on('click', function(){.....}) I also have a variable: var myActiveVar = $('#clickme'); When I want to remove the element an every trace of it I can do this: myActiveVar.off().remove(); Here comes the problem, I want to reuse the variable. Something like this: var oldAcriveVar = myActiveVar; myActiveVar = $('#clickme2'); // Now I want to do some operations // both of the elements are still on // the page, when I'm done: oldActiveVar.off().remove(); Comeplete code: var myActiveVar = $('#clickme'); // Operate on myActiveVar var oldAcriveVar = myActiveVar; myActiveVar = $('#clickme2'); // Operate on myActiveVar which is // the new element. // Old element stays visible oldActiveVar.off().remove(); // Old element and all traces are gone Edit: Maybe the above code will work, but my problem goes beyond. I just gave a simplified example. I am using Backbone events that are bounded to object. They need to be removed when I am done with the object.

    Read the article

  • How to access a variable outside a function in Javascript

    - by Luke101
    Here is the code I am working with: $(document).ready(function () { var TemplateEditor = function () { var GroupClassName = 'group'; var SelectedGroup = 0; var BindClicks = function () { $('.CriteriaSelections').unbind('click').click(function (event) { event.preventDefault(); if (fnIsTheClickedBoxaGroup($(this))) { TemplateEditor.GroupClicked(); } else { TemplateEditor.CriteriaClicked($(this), SelectedGroup); } }); $('.groupselected').unbind('click').click(function (event) { event.preventDefault(); SelectedGroup = $(this).attr('group-'.length); TemplateEditor.SelectGroup(SelectedGroup); }); } var fnGetGroupID = function (Obj) { if (fnIsTheClickedBoxaGroup(Obj) == true) { return null; } else { //Get parent which is the group var ObjParent = Obj.parent(); var GID = ObjParent.attr('id').substr('group-'.length); return GID; } } var fnIsTheClickedBoxaGroup = function (Obj) { var GetClass = Obj.attr('class'); if (GetClass == GroupClassName) { return true; } else { return false; } } return { Init: function () { BindClicks(); }, CriteriaClicked: function (Obj, GroupID) { $('<div>').attr({ id: '' }).addClass('selection').text(Obj).appendTo('#group-' + GroupID); }, GroupClicked: function () { }, SelectGroupClicked: function () { }, UpdateTargetPanel: function () { } }; } (); TemplateEditor.Init(); }); I am trying to access this variable: GroupClassName This variable is inside this function var fnIsTheClickedBoxaGroup = function (Obj) { var GetClass = Obj.attr('class'); if (GetClass == GroupClassName) { return true; } else { return false; } } When I run the program it says GroupClassName is undefined. Am I missing something here?

    Read the article

  • C++ reference variable again!!!

    - by kumar_m_kiran
    Hi All, I think most would be surprised about the topic again, However I am referring to a book "C++ Common Knowledge: Essential Intermediate Programming" written by "Stephen C. Dewhurst". In the book, he quotes a particular sentence (in section under Item 5. References Are Aliases, Not Pointers), which is as below A reference is an alias for an object that already exists prior to the initialization of the reference. Once a reference is initialized to refer to a particular object, it cannot later be made to refer to a different object; a reference is bound to its initializer for its whole lifetime Can anyone please explain the context of "cannot later be made to refer to a different object" Below code works for me, #include <iostream> using namespace std; int main(int argc, char *argv[]) { int i = 100; int& ref = i; cout<<ref<<endl; int k = 2000; ref = k; cout<<ref<<endl; return 0; } Here I am referring the variable ref to both i and j variable. And the code works perfectly fine. Am I missing something? I have used SUSE10 64bit linux for testing my sample program. Thanks for your input in advance.

    Read the article

  • PHP variable equals true no matter what the value, even 0

    - by kaigoh
    This is the var_dump: object(stdClass)#27 (8) { ["SETTING_ID"]=> string(2) "25" ["SETTING_SOURCE"]=> string(2) "XV" ["SETTING_FLEET"]=> string(3) "313" ["SETTING_EXAM"]=> string(1) "A" ["SETTING_HIDE"]=> string(1) "0" ["SETTING_THRESHOLD"]=> string(1) "0" ["SETTING_COUNT"]=> string(8) "POSITIVE" ["SETTING_USAGE"]=> string(7) "MILEAGE" } The variable I am testing is SETTING_HIDE. This is being pulled from MySQL using the Code igniter framework. I don't know if it is just me being thick after a rather long day at work or what, but no matter what value the variable holds, any if statement made against it returns true, even when typecast as a boolean or a direct string comparison, ie. == "0" or == "1". Anyone with a fresh pair of eyes care to make me feel silly!?! :) Just to clarify: Have tried the following: if($examSetting->SETTING_HIDE == "1") { $showOnABC = "checked=\"checked\""; } if((bool)$examSetting->SETTING_HIDE) { $showOnABC = "checked=\"checked\""; } if($examSetting->SETTING_COUNT == "POSITIVE") further on in my code works perfectly.

    Read the article

  • Is `super` local variable?

    - by Michael
    // A : Parent @implementation A -(id) init { // change self here then return it } @end A A *a = [[A alloc] init]; a. Just wondering, if self is a local variable or global? If it's local then what is the point of self = [super init] in init? I can successfully define some local variable and use like this, why would I need to assign it to self. -(id) init { id tmp = [super init]; if(tmp != nil) { //do stuff } return tmp; } b. If [super init] returns some other object instance and I have to overwrite self then I will not be able to access A's methods any more, since it will be completely new object? Am I right? c. super and self pointing to the same memory and the major difference between them is method lookup order. Am I right? sorry, don't have Mac to try, learning theory as for now...

    Read the article

  • How to evaluate json member using variable ?

    - by Miftah
    Hi i've got a problem evaluating json. My goal is to insert json member value to a function variable, take a look at this function func_load_session(svar){ var id = ''; $.getJSON('data/session.php?load='+svar, function(json){ eval('id = json.'+svar); }); return id; } this code i load session from php file that i've store beforehand. i store that session variable using dynamic var. <?php /* * format ?var=[nama_var]&val=[nilai_nama_var] */ $var = $_GET['var']; $val = $_GET['val']; $load = $_GET['load']; session_start(); if($var){ $_SESSION["$var"] = $val; echo "Store SESSION[\"$var\"] = '".$_SESSION["$var"]."'"; }else if($load){ echo $_SESSION["$load"]; } ?> using firebug, i get expected response but i also received error uncaught exception: Syntax error, unrecognized expression: ) pointing at this eval('id = json.'+svar); i wonder how to solve this

    Read the article

  • Creating a new variable in C from only part of an existing u_char

    - by Alex Kloss
    I'm writing some C code to parse IEEE 802.11 frames, but I'm stuck trying to create a new variable whose length depends on the size of the frame itself. Here's the code I currently have: int frame_body_len = pkt_hdr->len - radio_hdr->len - wifi_hdr_len - 4; u_char *frame_body = (u_char *) (packet + radio_hdr->len + wifi_hdr_len); Basically, the frame consists of a header, a body, and a checksum at the end. I can calculate the length of the frame body by taking the length of the packet and subtracting the length of the two headers that appear before it (radio_hdr->len and wifi_hdr_len respectively), plus 4 bytes at the end for the checksum. However, how can I create the frame_body variable without the trailing checksum? Right now, I'm initializing it with the contents of the packet starting at the position after the two headers, but is there some way to start at that position and end 4 bytes before the end of packet? packet is a pointer to a u_char, if it helps. I'm a new C programmer, so any and all advice about my code you can give me would be much appreciated. Thanks!

    Read the article

  • Trying to instantiate a class member in C++ with a variable name

    - by MarcZero
    Hello. I am writing a program for class that is asking us to create a class of "book". We are then supposed to create new instantiations of that class upon demand from the user. I am new to C++ so I am attempting to code this out but am running into a problem. The main problem is how do I instantiate a class with a variable if I don't know how many I will have to do ahead of time. The user could ask to add 1 book or 1000. I am looking at this basic code: This is the simple code I started with. I wanted to have an index int keep a number and have the book class I create be called by that int (0, 1, 2, etc...) So I attempted to convert the incoming index int into a string, but I'm kind of stuck from here. void addBook(int index){ string bookName; std::stringstream ss; ss << index; book bookName; cout << "Enter the Books Title: "; cin >> bookName.title; } But obviously this doesn't work as "bookName" is a string to the computer and not the class member I tried to create. All of the tutorials I have seen online and in my text show the classes being instantiated with names in the code, but I just don't know how to make it variable so I can create any amount of "books" that the user might want. Any insight on this would be appreciated. Thank you for your time.

    Read the article

  • How do I execute a sql statement through a variable (dyname sql) that tries to do an insert into a variable table?

    - by Testifier
    If I do what I wanna do with a TEMPORARY TABLE, it works fine: DECLARE @CTRFR VARCHAR(MAX) SET @CTRFR = 'select blah blah blah' -- <-- very long select statement. this returns a 0 or some greater number. Please note! --> I NEED THIS NUMBER. IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo][#CTRFRResult]') AND type IN ( N'U' ) ) DROP TABLE [dbo].[#CTRFRResult] CREATE TABLE #CTRFRResult ( CTRFRResult VARCHAR(MAX) ) SET @CTRFR = 'insert into #CTRFRResult ' + @CTRFR EXEC(@CTRFR) The above works fine. The problem is that several databases are using the same TEMP table. Therefore I need to use a VARIABLE table (instead of a temporary table). What I have below is not working because it says that the table must be declared. DECLARE @CTRFRResult TABLE ( CTRFRResult VARCHAR(MAX) ) SET @CTRFR = 'insert into @CTRFRResult ' + @CTRFR -- I think the issue is here. EXEC(@CTRFR) Setting @CTRFR to 'insert into...' is not working because I'm assuming the table name is out of scope. How would I go about mimicking the temporary table code using a variable table?

    Read the article

  • Changing PHP variable from an <a href=""> link

    - by aener
    I'm making a site using divs. I have one across the top with a row of links which I want to change what's in the main window. I would prefer to keep strictly to PHP and HTML and use a full page refresh as I am comfortable with them at current, rather than using an Ajax refresh as I don't have any knowledge of Ajax. I don't want to use iframes. I thought the best way to do this would be as follows: <div id="top"> <a href="news.html">News</a> </div> <div id="main"> <?php include($page); ?> </div> What I need is a way of changing the $page variable upon clicking the link. If this means changing the variable and then reloading the page then so be it. A command following the logic of: <a href="news.html" action="<?php $page="news.html"; ?>">News</a> would be ideal! I thought about using a form, but it seems there should be an easier way.

    Read the article

  • Share variable across site ASP.NET

    - by Anders
    I have a class isSearching with a single boolean property in a 'functions' file in my webapp. On my search page, I have a variable oSearchHandler declared as a Public Shared variable. How can I access the contents of oSearchHandler on other pages in my webapp? Code with Session.... 'search.aspx Public Function oSearchString(ByVal oTextBoxName As String) As String For Each oKey As String In Request.Form.AllKeys If oKey.Contains(oTextBoxName) Then Session.Add("searching", True) Session.Add("search-term", Request.Form(oKey)) Return Request.Form(oKey) End If Next Return "" End Function 'theMaster.master <% If Session("searching") Then %><ul style="float: right;"> <li> <div class="gsSearch"> <asp:TextBox ID="searchbox" runat="server"></asp:TextBox> </div> </li> <li> <div class="gsSearch"> <asp:Button ID="searchbutton" runat="server" Text="search" UseSubmitBehavior="true" PostBackUrl="search.aspx" CssClass="searchBtn" /> </div> </li> </ul> <% End If %> I think that the session will work just fine.

    Read the article

  • Assigning jQuery ajax response text to variable constanty returns null

    - by Dan Twining
    Hi all, hopefully one of you on this great site can help. I'm having issues with assigning a variable to a jQuery ajax call response text. I have a form which when submited runs my "checkemail" function to varify the email address can be found in a database. If it's found, the responseText == "true", else "false". This works fine, and can be seen ok using Firebug....but the actual variable the response text should be assigned to is constantly showing "", and therefore causing the function to return false all the time. function checkemail(){ var EmailFromForm = $("#lostemail").val(); var EmailCheckRes = $.ajax({ type : "POST", cache : false, url : "./scripts/passreset/emailcheck.php", data : "Email="+EmailFromForm, dataType : "text", }).responseText; if (EmailCheckRes == "true") { alert("Should say true: " + EmailCheckRes); return true; } else { $("#ErrorMsg").html("Your email address is either invalid or not found."); alert("Should say false: " + EmailCheckRes); return false; } } If anyone has any pointers as to what i'm doing wrong it'd be greatly appreciated.

    Read the article

  • Change $mailTo variable based on select input value (array)

    - by Dirty Bird Design
    I have the following select list: <form action="mail.php" method="POST"> <select name="foo" id="foo"> <option value="sales">Sales</option> <option value="salesAssist">Sales Assist</option> <option value="billing">Billing</option> <option value="billingAssist">Billing Assist</option> </select> </form> I need to route the $mailTo variable depending on which option they select, Sales and Sales Assist go to [email protected], while Billing and Billing Assist go to [email protected] PHP pseudeo code! <? php $_POST['foo'] if inArray(sales, salesAssist) foo="[email protected]"; else if inArray(billing, billingAssist) foo="[email protected]"; mailTo="foo" ?> I know there is nothing correct about the above, but you can see what I am trying to do, change a variable's value based on the selected value. I don't want to do this with JS, would rather learn more PHP here. Thank you.

    Read the article

  • data is not posted in $_POST variable using AJAX [migrated]

    - by Oliver
    Im having a problem in one of my script. Server is running in php, and im using AJAX to post data. Here is my script. PHP script: 0){ echo "Search Result :"; for ($x=0;$xProject Name:   ".mysql_result($result,$x,"projname").""; echo "APMS ID:   ".mysql_result($result,$x,"apmsid").""; echo "Prefix/es:   ".mysql_result($result,$x,"projprefix").""; echo "Usage Type:   ".mysql_result($result,$x,"usagetype").""; echo "Rate:   ".mysql_result($result,$x,"projrate").""; echo "Offer Details:   ".mysql_result($result,$x,"offerdetails").""; } }else{ echo "No results found ..."; } }else{ echo "Problems encountered while processing the data ..."; } ? JS Script: function QueryPrefix() { var xmlhttp; var pStr = document.getElementById('Editbox2'); var htmlHolder = document.getElementById('Html1'); var butStr = document.getElementById('Button1'); if (pStr.value.length == 0){ alert("Please enter a value on the box provided!"); return; } pStr.value=""; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { htmlHolder.innerHTML=xmlhttp.responseText; butStr.disabled=false; } } butStr.disabled=true; xmlhttp.open("POST","searchutype.php",false); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send("pStr=" + pStr.value); }

    Read the article

  • Flexible/variable/wildcard vhosts/hosts

    - by Moak
    I am using wamp, have all my projects in E:\webs\*projectname*\htdocs I want to access all of them in my browser with http://*projectname*.loc is there a way i can set up hosts and vhosts files so i never have to open them again? note this is for my own personal use, and I can change from .loc to .whatever if ICANN decides to start selling .loc domains.

    Read the article

  • Flexible/variable vhosts/hosts

    - by Moak
    I am using wamp, have all my projects in E:\webs\*projectname*\htdocs I want to access all of them in my browser with http://*projectname*.loc is there a way i can set up hosts and vhosts files so i never have to open them again? note this is for my own personal use, and I can change from .loc to .whatever if ICANN decides to start selling .loc domains.

    Read the article

  • emacs error: "Symbol's value as variable is void: hostname"

    - by Florian Pilz
    After I installed emacs this error occurs every time on startup. It prevents me from installing plugins, e.g. auctex via aptitude. I already tried to install a plugin by hand (rails for ruby), but doesn't work. The error doesn't contain the message "hostname", but the hostname of my PC is displayed ("bloodredangel-ubuntu"). I changed my hostname to "bloodredangel", but the error message stays the same. While I changed my hostname I saw that in /etc/hostname were two entries: 127.0.0.1 bloodredangel-ubuntu I already asked this question in an ubuntu forum but they couldn't help. They recognised an misconfigured /etc/hosts file, which I corrected, but from time to time these incorrect configurations get attached by something. I didn't add them by hand, maybe it has something to do with the issue. The misconfigurations looked like this: 127.0.0.1 127.0.0.1 bloodredangel-ubuntu localhost.localdomain localhost 127.0.0.1 127.0.0.1:8080 bloodredangel-ubuntu localhost.localdomain localhost I didn't found a solution on the internet, so I hope I will find help here finally.

    Read the article

  • Implication of variable context switching time

    - by Rob
    Hi, I know that constant switching time of the Linux scheduler was a big achievement. I was just asking myself the question what would be the implication of a non-constant switching time. The only obvious reason I can think of is real-time systems where we have to meet deadlines. There it is obviously no ideal if the switching time is "random". Are there any other good reasons that favour constant switching times? Many thanks, Rob

    Read the article

  • ash scripting: space-containing variable refuses to be grepped

    - by Luci Sandor
    I am trying to run the script listed at http://talk.maemo.org/showthread.php?t=70866&page=2 on its intended hardware, a Nokia Linux phone running BusyBox ash. The script receives the name of WiFi network as a parameter, and tries to connect the phone to it. I suspect the script works, but my SSID, BU (802.1x), has space and parentheses in it. So when I type at the command prompt autoconnect.sh BU\ \(802.1x\) I get various errors. First, LIST=`iwconfig wlan0 | awk -F":" '/ESSID/{print $2}'` if [ $LIST = "\"$1\"" ]; then ...fails, even I am connected to the network. The error is not avoided by using single or double quotes instead of escaping characters at the command prompt. Second, if [ -z `iwlist wlan0 scan | grep -m 1 -o \"$1\"` ]; then echo SSID \"$1\" not found; shows that grep does not find the string, although the same grep, typed directly into the command prompt, does find 'BU (802.1x)'. How do I quote $1 in the two circumstances above so that it will work with my network SSID, containing spaces and parentheses? Thank you.

    Read the article

  • emacs error: "Symbol's value as variable is void: hostname"

    - by Florian Pilz
    After I installed emacs this error occurs every time on startup. It prevents me from installing plugins, e.g. auctex via aptitude. I already tried to install a plugin by hand (rails for ruby), but doesn't work. The error doesn't contain the message "hostname", but the hostname of my PC is displayed ("bloodredangel-ubuntu"). I changed my hostname to "bloodredangel", but the error message stays the same. While I changed my hostname I saw that in /etc/hostname were two entries: 127.0.0.1 bloodredangel-ubuntu I already asked this question in an ubuntu forum but they couldn't help. They recognised an misconfigured /etc/hosts file, which I corrected, but from time to time these incorrect configurations get attached by something. I didn't add them by hand, maybe it has something to do with the issue. The misconfigurations looked like this: 127.0.0.1 127.0.0.1 bloodredangel-ubuntu localhost.localdomain localhost 127.0.0.1 127.0.0.1:8080 bloodredangel-ubuntu localhost.localdomain localhost I didn't found a solution on the internet, so I hope I will find help here finally.

    Read the article

  • pam_exec.so PAM module does not export variable PAM_USER as stated in the documentation

    - by davidparks21
    I'm trying to use the pam_exec.so PAM module to execute a script which needs to know the username/password coming from the application (OpenVPN in this case). I have a script that executes printenv >>afile, but I don't see all the environment variables that the man pages states that pam_exec.so exports (namely PAM_USER I think), I only see the following: PAM_SERVICE=openvpn PAM_TYPE=auth PWD=/usr/local/openvpn/bin SHLVL=1 A__z="*SHLVL I do successfully pick up the password off of STDIN and output it with this same script. But for the life of me I can't get the username. Any thoughts on what I should try next?

    Read the article

  • Puppet&Hiera: $variable is not an hash or array when accessing it

    - by txworking
    I wrote a puppet module and the content of init.pp was: class install( $common_instanceconfig = hiera_hash('common_instanceconfig'), $common_instances = hiera('common_instances') ) { define instances { common { $title: name => $title, path => $common_instanceconfig[$title]['path'], version => $common_instanceconfig[$title]['version'], files => $common_instanceconfig[$title]['files'], pre => $common_instanceconfig[$title]['pre'], after => $common_instanceconfig[$title]['after'], properties => $common_instanceconfig[$title]['properties'], require => $common_instanceconfig[$title]['require'] , } } instances {$common_instances:} } And the hieradata file was: classes: - install common_instances: - common_instance_1 - common_instance_2 common_instanceconfig: common_instance_1 path : '/opt/common_instance_1' version : 1.0 files : software-1.bin pre : pre_install.sh after : after_install.sh properties: "properties" common_instance_2: path : '/opt/common_instance_2' version : 2.0 files : software-2.bin pre : pre_install.sh after : after_install.sh properties: "properties" I always got a error message When puppet agent run Error: common_instanceconfig String is not an hash or array when accessing it with common_instance_1 at /etc/puppet/modules/install/manifests/init.pp:16 on node puppet.agent1.tmp It seems $common_instances can be got correctly, but $commono_instanceconfig always be treated as a string. I used YAML.load_file to load the hieradata file, and got a correct hash object. Can anybody help?

    Read the article

  • How to add a variable into a grep command

    - by twigg
    I'm running the following grep command var=`grep -n "keyword" /var/www/test/testfile.txt` This work just as expected but I need to insert the file name dynamically from a loop like so: var=`grep -n "keyword" /var/www/test/`basename ${hd[$i]}`.txt` But obviously the use of ` brakes this with a unexpected EOF while looking for matching ``' and unexpected end of file Any ideas of away around this?

    Read the article

< Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >