Search Results

Search found 3096 results on 124 pages for 'scope creep'.

Page 16/124 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Pro/con of using Angular directives for complex form validation/ GUI manipulation

    - by tengen
    I am building a new SPA front end to replace an existing enterprise's legacy hodgepodge of systems that are outdated and in need of updating. I am new to angular, and wanted to see if the community could give me some perspective. I'll state my problem, and then ask my question. I have to generate several series of check boxes based on data from a .js include, with data like this: $scope.fieldMappings.investmentObjectiveMap = [ {'id':"CAPITAL PRESERVATION", 'name':"Capital Preservation"}, {'id':"STABLE", 'name':"Moderate"}, {'id':"BALANCED", 'name':"Moderate Growth"}, // etc {'id':"NONE", 'name':"None"} ]; The checkboxes are created using an ng-repeat, like this: <div ng-repeat="investmentObjective in fieldMappings.investmentObjectiveMap"> ... </div> However, I needed the values represented by the checkboxes to map to a different model (not just 2-way-bound to the fieldmappings object). To accomplish this, I created a directive, which accepts a destination array destarray which is eventually mapped to the model. I also know I need to handle some very specific gui controls, such as unchecking "None" if anything else gets checked, or checking "None" if everything else gets unchecked. Also, "None" won't be an option in every group of checkboxes, so the directive needs to be generic enough to accept a validation function that can fiddle with the checked state of the checkbox group's inputs based on what's already clicked, but smart enough not to break if there is no option called "NONE". I started to do that by adding an ng-click which invoked a function in the controller, but in looking around Stack Overflow, I read people saying that its bad to put DOM manipulation code inside your controller - it should go in directives. So do I need another directive? So far: (html): <input my-checkbox-group type="checkbox" fieldobj="investmentObjective" ng-click="validationfunc()" validationfunc="clearOnNone()" destarray="investor.investmentObjective" /> Directive code: .directive("myCheckboxGroup", function () { return { restrict: "A", scope: { destarray: "=", // the source of all the checkbox values fieldobj: "=", // the array the values came from validationfunc: "&" // the function to be called for validation (optional) }, link: function (scope, elem, attrs) { if (scope.destarray.indexOf(scope.fieldobj.id) !== -1) { elem[0].checked = true; } elem.bind('click', function () { var index = scope.destarray.indexOf(scope.fieldobj.id); if (elem[0].checked) { if (index === -1) { scope.destarray.push(scope.fieldobj.id); } } else { if (index !== -1) { scope.destarray.splice(index, 1); } } }); } }; }) .js controller snippet: .controller( 'SuitabilityCtrl', ['$scope', function ( $scope ) { $scope.clearOnNone = function() { // naughty jQuery DOM manipulation code that // looks at checkboxes and checks/unchecks as needed }; The above code is done and works fine, except the naughty jquery code in clearOnNone(), which is why I wrote this question. And here is my question: after ALL this, I think to myself - I could be done already if I just manually handled all this GUI logic and validation junk with jQuery written in my controller. At what point does it become foolish to write these complicated directives that future developers will have to puzzle over more than if I had just written jQuery code that 99% of us would understand with a glance? How do other developers draw the line? I see this all over Stack Overflow. For example, this question seems like it could be answered with a dozen lines of straightforward jQuery, yet he has opted to do it the angular way, with a directive and a partial... it seems like a lot of work for a simple problem. Specifically, I suppose I would like to know: how SHOULD I be writing the code that checks whether "None" has been selected (if it exists as an option in this group of checkboxes), and then check/uncheck the other boxes accordingly? A more complex directive? I can't believe I'm the only developer that is having to implement code that is more complex than needed just to satisfy an opinionated framework.

    Read the article

  • Variable scoping and the jQuery.getJSON() method

    - by jerome
    The jQuery.getJSON() method seems to ignore the normal rules of scoping within JavaScript. Given code such as this... someObject = { someMethod: function(){ var foo; $.getJSON('http://www.somewhere.com/some_resource', function(data){ foo = data.bar; }); alert(foo); // undefined } } someObject.someMethod(); Is there a best practice for accessing the value of the variable outside of the getJSON scope?

    Read the article

  • Can I access Spring session-scoped beans from application-scoped beans? How?

    - by Corvus
    I'm trying to make this 2-player web game application using Spring MVC. I have session-scoped beans Player and application-scoped bean GameList, which creates and stores Game instances and passes them to Players. On player creates a game and gets its ID from GameList and other player sends ID to GameList and gets Game instance. The Game instance has its players as attributes. Problem is that each player sees only himself instead of the other one. Example of what each player sees: First player (Alice) creates a game: Creator: Alice, Joiner: Empty Second player (Bob) joins the game: Creator: Bob, Joiner: Bob First player refreshes her browser Creator: Alice, Joiner: Alice What I want them to see is Creator: Alice, Joiner: Bob. Easy way to achieve this is saving information about players instead of references to players, but the game object needs to call methods on its player objects, so this is not a solution. I think it's because of aop:scoped-proxy of session-scoped Player bean. If I understand this, the Game object has reference to proxy, which refers to Player object of current session. Can Game instance save/access the other Player objects somehow? beans in dispatcher-servlet.xml: <bean id="userDao" class="authorization.UserDaoFakeImpl" /> <bean id="gameList" class="model.GameList" /> <bean name="/init/*" class="controller.InitController" > <property name="gameList" ref="gameList" /> <property name="game" ref="game" /> <property name="player" ref="player" /> </bean> <bean id="game" class="model.GameContainer" scope="session"> <aop:scoped-proxy/> </bean> <bean id="player" class="beans.Player" scope="session"> <aop:scoped-proxy/> </bean> methods in controller.InitController private GameList gameList; private GameContainer game; private Player player; public ModelAndView create(HttpServletRequest request, HttpServletResponse response) throws Exception { game.setGame(gameList.create(player)); return new ModelAndView("redirect:game"); } public ModelAndView join(HttpServletRequest request, HttpServletResponse response, GameId gameId) throws Exception { game.setGame(gameList.join(player, gameId.getId())); return new ModelAndView("redirect:game"); } called methods in model.gameList public Game create(Player creator) { Integer code = generateCode(); Game game = new Game(creator, code); games.put(code, game); return game; } public Game join(Player joiner, Integer code) { Game game = games.get(code); if (game!=null) { game.setJoiner(joiner); } return game; }

    Read the article

  • Setting default_scope according to some criteria

    - by Tam
    I'm trying to set default scope according to some criteria determined by ana ActionController before_filter. In controller: before_filter :authorize ... def authorize if some_condition @default_scope_conditions = something elsif another_condition @default_scope_conditions = something_else end end Inside the ActiveRecord default_scope :conditions => @default_scope_conditions But it doesn't seem to work, the before filter gets called but the default_scope doesn't get set. Could you please advise me what I'm doing wrong and how to fix it or suggest me some other way of achieving that.

    Read the article

  • Lifetime of a const string literal returned by a function

    - by Neeraj
    Consider this code: const char* someFun() { // ... some stuff return "Some text!!" } int main() { { // Block: A const char* retStr = someFun(); // use retStr } } My question is in the function sumFun() where is "some Text!!", stored (i think may be in some static area in ROM) and what will be its scope? Will the memory pointed by retStr be occupied throughout the program or be released once the block A exits? -- Thanks

    Read the article

  • JQuery will not set a higher scoped object in callback

    - by user344666
    Hello, I have a jquery callback function. In that function I want it to change the value of a varible that is in a higher scope, for somereason it is not doing that. Here is the code. Thanks function add() { var returnedData = { my_id: 0 }; $.post("add_event.php", { event : toSendText }, function(data) {returnedData.my_id = 5;}, "json"); if(add_page == true){ alert(returnedData.my_id); window.open('content-list.php?cal_id='); } }

    Read the article

  • Mixed declarations and code in open source projects?

    - by Eduardo
    Why is still C99 mixed declarations and code not used in open source C projects like the Linux kernel or GNOME? I really like mixed declarations and code since it makes the code more readable and prevents hard to see bugs by restricting the scope of the variables to the narrowest possible. This is recommended by Google for C++. For example, Linux requires at least GCC 3.2 and GCC 3.1 has support for C99 mixed declarations and code

    Read the article

  • C99 mixed declarations and code in open source projects?

    - by Eduardo
    Why is still C99 mixed declarations and code not used in open source C projects like the Linux kernel or GNOME? I really like mixed declarations and code since it makes the code more readable and prevents hard to see bugs by restricting the scope of the variables to the narrowest possible. This is recommended by Google for C++. For example, Linux requires at least GCC 3.2 and GCC 3.1 has support for C99 mixed declarations and code

    Read the article

  • Object allocation in C++

    - by Poiuyt
    char *myfunc() { char *temp = "string"; return temp; } In this piece of code, where does the allocation of the object pointed to by temp happen and what would be its scope? Is this function a valid way to return a char* pointer?

    Read the article

  • How to access a (shadowed) global function in ruby.

    - by yngvedh
    Hi, I was wondering how to access a global function fn in ruby from a class which also defined a method fn. I have made a workaround by aliasing the function like so: def fn end class Bar alias global_fn fn def fn # how to access the global fn here without the alias global_fn end end I'm looking for something along the lines of c++'s :: to access global scope but I can't seem to locate any information about it. I guess I don't know specifically what I'm looking for.

    Read the article

  • JBoss Seam: In ScopeType.PAGE I get: java.lang.IllegalStateException: No conversation context active

    - by Markos Fragkakis
    Hi all, I have a page-scoped component, which has an instance variable List with data, which I display in a datatable. This datatable has pagination, sorting and filtering. The first time gate into the page, I get this appended in my URL: ?conversationId=97. The page works correctly, and when I change datatable pages no now component is created. After a minute or two, and at seamingly random time, I get an exception saying that there is no context. I have not used @Create in my code or my navigation files. So, I have two questions: Why do I get this suffix in my URL? Why did a conversation start? Why the exception? The component is scoped to PAGE. If I received an exception, it should not be related to a conversation. Right? Or is the conversation the exception is referring a temporary conversation? Cheers! UPDATE: This is the page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <body> <ui:composition template="/WEB-INF/facelets/templates/template.xhtml"> <ui:define name="content"> <!-- This method returns focus on the filter --> <script type="text/javascript"> function submitByEnter(event){ if (event.keyCode == 13) { if (event.preventDefault) { // Firefox event.preventDefault(); } else { // IE event.returnValue = false; } document.getElementById("refreshButton").click(); } } </script> <h:form prependId="false"> <h:commandButton action="Back" value="Back to home page" /> <br /> <p><h:outputText value="Applicants and Products (experimentation page)" class="page_title" /></p> <h:commandButton action="#{applicantProductListBean.showCreateApplicant}" value="Create Applicant" id="createApplicantButton"> </h:commandButton> <a4j:commandButton value="Refresh" id="refreshButton" action="#{applicantProductListBean.refreshData}" image="/images/icons/refresh48x48.gif" reRender="compositeTable, compositeScroller"> <!-- <f:setPropertyActionListener--> <!-- target="# {pageScrollerBean.applicantProductListPage}" value="1" />--> </a4j:commandButton> <rich:toolTip for="createApplicantButton" value="Create Applicant" /> <rich:dataTable styleClass="composite2DataTable" id="compositeTable" rows="1" columnClasses="col" value="#{applicantProductListBean.dataModel}" var="pageAppList"> <f:facet name="header"> <rich:columnGroup> <rich:column colspan="3"> <h:outputText styleClass="headerText" value="Applicants" /> </rich:column> <rich:column colspan="3"> <h:outputText styleClass="headerText" value="Products" /> </rich:column> <rich:column breakBefore="true"> <h:outputText styleClass="headerText" value="Applicant Name" /> <a4j:commandButton id="sortingApplicantNameButton" action="#{applicantProductListBean.toggleSorting('applicantName')}" image="/images/icons/sorting/#{sortingFilteringBean.applicantProductListSorting.sortingValues['applicantName']}.gif" reRender="sortingApplicantNameButton, sortingApplicantEmailButton, compositeTable, compositeScroller"> <!-- <f:setPropertyActionListener--> <!-- target="#{pageScrollerBean.applicantProductListPage}" value="1" />--> </a4j:commandButton> <br /> <h:inputText value="#{sortingFilteringBean.applicantProductListFiltering.filteringValues['applicantName']}" id="applicantNameFilterValue" onkeypress="return submitByEnter(event)"> </h:inputText> </rich:column> <rich:column> <h:outputText styleClass="headerText" value="Applicant Email" /> <a4j:commandButton id="sortingApplicantEmailButton" action="#{applicantProductListBean.toggleSorting('applicantEmail')}" image="/images/icons/sorting/#{sortingFilteringBean.applicantProductListSorting.sortingValues['applicantEmail']}.gif" reRender="sortingApplicantNameButton, sortingApplicantEmailButton, compositeTable, compositeScroller"> <!-- <f:setPropertyActionListener--> <!-- target="#{pageScrollerBean.applicantProductListPage}" value="1" />--> </a4j:commandButton> <br /> <h:inputText value="#{sortingFilteringBean.applicantProductListFiltering.filteringValues['applicantEmail']}" id="applicantEmailFilterValue" onkeypress="return submitByEnter(event)"> </h:inputText> </rich:column> <rich:column> <h:outputText styleClass="headerText" value="Applicant Actions" /> </rich:column> <rich:column> <h:outputText styleClass="headerText" value="Product Name" /> <a4j:commandButton id="sortingProductNameButton" action="#{applicantProductListBean.toggleSorting('productName')}" immediate="true" image="/images/icons/sorting/#{sortingFilteringBean.applicantProductListSorting.sortingValues['productName']}.gif" reRender="sortingProductNameButton, compositeTable, compositeScroller"> </a4j:commandButton> <br /> <h:inputText value="#{sortingFilteringBean.applicantProductListFiltering.filteringValues['productName']}" id="productNameFilterValue" onkeypress="return submitByEnter(event)"> </h:inputText> </rich:column> <rich:column> <h:outputText styleClass="headerText" value="Product Email" /> <br /> <h:inputText value="#{sortingFilteringBean.applicantProductListFiltering.filteringValues['productEmail']}" id="productEmailFilterValue" onkeypress="return submitByEnter(event)"> </h:inputText> </rich:column> <rich:column> <h:outputText styleClass="headerText" value="Product Actions" /> </rich:column> </rich:columnGroup> </f:facet> <rich:subTable rowClasses="odd_applicant_row, even_applicant_row" value="#{pageAppList}" var="app"> <rich:column styleClass=" internal_cell composite2TextContainingColumn" valign="top"> <h:outputText value="#{app.name}" /> </rich:column> <rich:column styleClass="internal_cell composite2TextContainingColumn" valign="top"> <h:outputText value="#{app.receiptEmail}" /> </rich:column> <rich:column valign="top" styleClass="buttonsColumn"> <h:commandButton action="#{applicantProductListBean.showUpdateApplicant(app)}" image="/images/icons/edit.jpg"> </h:commandButton> <!-- <rich:toolTip for="editApplicantButton" value="Edit Applicant" />--> <h:commandButton action="#{applicantProductListBean.showDeleteApplicant(app)}" image="/images/icons/delete.png"> </h:commandButton> <!-- <rich:toolTip for="deleteApplicantButton" value="Delete Applicant" />--> </rich:column> <rich:column colspan="3"> <table class="productsTableTable"> <tbody> <tr> <td class="createProductButtonTableCell"><h:commandButton action="#{applicantProductListBean.showCreateProduct(app)}" value="Create Product"> </h:commandButton> <!-- <rich:toolTip for="createProductButton" value="Create Product" />--> </td> </tr> <tr> <td><rich:dataTable value="#{app.products}" var="prod" rowClasses="odd_product_row, even_product_row"> <rich:column styleClass="internal_cell composite2TextContainingColumn"> <h:outputText value="#{prod.inventedName}" /> </rich:column> <rich:column styleClass="internal_cell composite2TextContainingColumn"> <h:outputText value="#{prod.receiptEmail}" /> </rich:column> <rich:column styleClass="buttonsColumn"> <h:commandButton action="#{applicantProductListBean.showUpdateProduct(prod)}" image="/images/icons/edit.jpg"> </h:commandButton> <!-- <rich:toolTip for="editProductButton" value="Edit Product" />--> <h:commandButton action="#{applicantProductListBean.showDeleteProduct(prod)}" image="/images/icons/delete.png"> <f:setPropertyActionListener target="#{productBean.product}" value="#{prod}" /> </h:commandButton> <!-- <rich:toolTip for="deleteProductButton" value="Delete Product" />--> </rich:column> </rich:dataTable></td> </tr> </tbody> </table> </rich:column> </rich:subTable> <f:facet name="footer"> <h:panelGrid columns="1" styleClass="applicantProductListFooter"> <h:outputText value="#{msgs.no_results}" rendered="#{(empty applicantProductListBean.dataModel) || (applicantProductListBean.dataModel.rowCount==0)}"/> <rich:datascroller align="center" for="compositeTable" page="#{pageScrollerBean.applicantProductListPage}" id="compositeScroller" reRender="compositeTable" renderIfSinglePage="false" fastControls="hide"> <f:facet name="first"> <h:outputText value="#{msgs.first}" styleClass="scrollerCell" /> </f:facet> <f:facet name="first_disabled"> <h:outputText value="#{msgs.first}" styleClass="scrollerCell" /> </f:facet> <f:facet name="last"> <h:outputText value="#{msgs.last}" styleClass="scrollerCell" /> </f:facet> <f:facet name="last_disabled"> <h:outputText value="#{msgs.last}" styleClass="scrollerCell" /> </f:facet> <f:facet name="next"> <h:outputText value="#{msgs.next}" styleClass="scrollerCell" /> </f:facet> <f:facet name="next_disabled"> <h:outputText value="#{msgs.next}" styleClass="scrollerCell" /> </f:facet> <f:facet name="previous"> <h:outputText value="#{msgs.previous}" styleClass="scrollerCell" /> </f:facet> <f:facet name="previous_disabled"> <h:outputText value="#{msgs.previous}" styleClass="scrollerCell" /> </f:facet> </rich:datascroller> </h:panelGrid> </f:facet> </rich:dataTable> </h:form> </ui:define> This is the backing bean: @Name("applicantProductListBean") @Scope(ScopeType.PAGE) public class ApplicantProductListBean extends BasePagedSortableFilterableListBean { /** * Public field for ad-hoc injection to work. */ @EJB(name = "FacadeService") public ApplicantFacadeService applicantFacadeService; @Logger private static Log logger; private final int pageSize = 10; @Out(scope = ScopeType.CONVERSATION, required = false) Applicant currentApplicant; @Out(scope = ScopeType.CONVERSATION, required = false) Product product; @Create public void onCreate() { System.out.println("Create"); } @Override protected DataModel initDataModel(int pageSize) { // get filtering and sorting from session sorting = getSorting(); filtering = getFiltering(); // System.out.println("Initializing a Composite3DataModel"); // System.out.println("Pagesize: " + pageSize); // System.out.println("Filtering: " + filtering.getFilteringValues()); // System.out.println("Sorting: " + sorting.getSortingValues()); return new Composite3DataModel(1, sorting, filtering); } // Navigation methods /** * Navigation-returning method, returns the action to follow after pressing * the "Create Applicant" button * * @return the action to be taken */ public Navigation.ApplicantProductList showCreateApplicant() { return Navigation.ApplicantProductList.SHOW_CREATE_APPLICANT; } /** * Navigation-returning method, returns the action to follow after pressing * the "Edit Applicant" button * * @return the action to be taken */ public Navigation.ApplicantProductList showUpdateApplicant( Applicant applicant) { this.currentApplicant = applicant; return Navigation.ApplicantProductList.SHOW_UPDATE_APPLICANT; } /** * Navigation-returning method, returns the action to follow after pressing * the "Delete Applicant" button * * @return the action to be taken */ public Navigation.ApplicantProductList showDeleteApplicant( Applicant applicant) { this.currentApplicant = applicant; return Navigation.ApplicantProductList.SHOW_DELETE_APPLICANT; } /** * Navigation-returning method, returns the action to follow after pressing * the "Create Product" button * * @return the action to be taken */ public Navigation.ApplicantProductList showCreateProduct(Applicant app) { this.product = new Product(); this.product.setApplicant(app); return Navigation.ApplicantProductList.SHOW_CREATE_PRODUCT; } /** * Navigation-returning method, returns the action to follow after pressing * the "Edit Product" button * * @return the action to be taken */ public Navigation.ApplicantProductList showUpdateProduct(Product prod) { this.product = prod; return Navigation.ApplicantProductList.SHOW_UPDATE_PRODUCT; } /** * Navigation-returning method, returns the action to follow after pressing * the "Delete Product" button * * @return the action to be taken */ public Navigation.ApplicantProductList showDeleteProduct(Product prod) { this.product = prod; return Navigation.ApplicantProductList.SHOW_DELETE_PRODUCT; } /** * */ @Override public Sorting getSorting() { if (sorting == null) { return (getSortingFilteringBeanFromSession() .getApplicantProductListSorting()); } return sorting; } /** * */ @Override public void setSorting(Sorting sorting) { getSortingFilteringBeanFromSession().setApplicantProductListSorting( sorting); } /** * */ @Override public Filtering getFiltering() { if (filtering == null) { return (getSortingFilteringBeanFromSession() .getApplicantProductListFiltering()); } return filtering; } /** * */ @Override public void setFiltering(Filtering filtering) { getSortingFilteringBeanFromSession().setApplicantProductListFiltering( filtering); } /** * @return the currentApplicant */ public Applicant getCurrentApplicant() { return currentApplicant; } /** * @param currentApplicant * the currentApplicant to set */ public void setCurrentApplicant(Applicant applicant) { this.currentApplicant = applicant; } /** * The model for this page * */ private class Composite3DataModel extends PagedSortableFilterableDataModel<List<Applicant>> { public Composite3DataModel(int pageSize, Sorting sorting, Filtering filtering) { super(pageSize, sorting, filtering); } @Override protected DataPage<List<Applicant>> fetchPage(int fakeStartRow, int fakePageSize) { // if (logger.isTraceEnabled()) { System.out.println("Getting page with fakeStartRow: " + fakeStartRow + " and fakePageSize " + fakePageSize); // } // to find the page size multiply the startRow and the fakePageSize // (which is 1) to the actual page size int startRow = fakeStartRow * ApplicantProductListBean.this.pageSize; int pageSize = fakePageSize * ApplicantProductListBean.this.pageSize; // if (logger.isTraceEnabled()) { System.out.println("Getting page with startRow: " + startRow + " and pageSize " + pageSize); // } List<Applicant> pageApplicants = applicantFacadeService .findPagedWithCriteria(startRow, pageSize, filtering, sorting); // List<Applicant> pageApplicants = applicantFacadeService // .findPagedWithDynamicQuery(startRow, pageSize, filtering, // sorting, true); // if (logger.isTraceEnabled()) { System.out.println("Set of applicants: " + pageApplicants.size()); // } List<List<Applicant>> pageApplicantsListContainer = new ArrayList<List<Applicant>>(); pageApplicantsListContainer.add(pageApplicants); DataPage<List<Applicant>> dataPage = new DataPage<List<Applicant>>( this.getRowCount(), fakeStartRow, pageApplicantsListContainer); return dataPage; } @Override protected int getDatasetSize() { // int size = getServiceFacade().countWithCriteria(filtering, // sorting); // int size = // applicantFacadeService.countWithDynamicQuery(filtering, sorting, // false); int size = (int) Math.ceil((double) applicantFacadeService .countWithCriteria(filtering, sorting, false) / pageSize); if (logger.isTraceEnabled()) { logger.trace("Got Dataset Size: " + size); } return size; } } /** * @return the product */ public Product getProduct() { return product; } /** * @param product * the product to set */ public void setProduct(Product product) { this.product = product; } }

    Read the article

  • Spring bean's DESTROY-METHOD attribute [does not work for me]

    - by EugeneP
    Can get work the attribute "destroy-method". First, even if I type non-existing method name into "destroy-method" attribute, Spring initialization completes fine (already strange!). Next, when a bean has a "prototype" scope, then I suppose it must be destroyed before the application is closed. That not happens, it is simply never called in my case. Though, after extracting this bean I can call this method explicitly and it does its job. Could you explain why this method is never called in my Spring 2.5 case? p.s. The method exists, it is public and has no arguments.

    Read the article

  • Error loading Variables stage.loaderInfo - AS3

    - by Dimitree
    I have a Document class that loads variables from Facebook with the use of stage.loaderInfo var connect:FacebookConnectObject = new FacebookConnectObject( facebook, API_KEY, this.stage.loaderInfo ); But when I change the Document class (with another one responsible for the layout of my app), and try call the above from a movieclip that exists in my application with the use: var facebook_class:FacebookAp = new FaceBppkApp addChild(facebook_class) I get error TypeError: Error #1009: Cannot access a property or method of a null object reference. I believe the error comes fro this line this.stage.loaderInfo since I changed the scope... How I am supposed to fix that?

    Read the article

  • Access variables from a number of sources

    - by mac_55
    I'm creating my first game, and I've currently set up a 'GameState' class, to store player health etc. inside. This class is currently instantiated from the AppDelegate as I need to access it from all over my game. This is fine. For each class I'm working in, I can access the app delegate, and then find the GameState object... however, it seems very messy. I'm tempted to find a way (I'm still a newbie) to define the GameState instance as being some sort of global variable so that I can access it from all over with ease... but my little bit of reading on variable scope makes me uneasy about doing this, even if I knew how. Any ideas of the best way to define and access this class? It'll be used for everything from player health, to items they've found, any personalisation etc. Thanks!

    Read the article

  • named_scope and substings

    - by Philb28
    I have a named_scope in rails that finds episodes by there directors given name named_scope :director_given, lambda { |dr| {:joins => :director, :conditions => ['given = ?', dr]} } It works great but I would like it to also work on substrings one the name. e.g. instead of having to search for 'Lucy' you could just search 'Lu'. P.S. I also have another named scope which does exactly the same thing but on the directors last name. It there a way to combine the two? Thanks,

    Read the article

  • What are the main advantages of adding your custom functions to a javascript libraries namepsace?

    - by yaya3
    It is fairly well known in JavaScript that declaring variables within the global scope is a bad thing. So code I tend to work on contains namespaced JavaScript. There seems to be two different approaches taken to this - Adding your application specific functions to the libraries' namespace e.g. $.myCarouselfunction Creating your own namespace e.g. MyApplication.myCarouselFunction I wanted to know whether or not there is a 'better' solution or if they tend to meet somewhere close in terms of pros and cons. The reason for me personally deciding not to go with the library is for Seperation / Isolation / Lack of conflict with library code and potential plugins that are likely to share that namespace. But I am sure there is more to this. Thanks

    Read the article

  • WPF UserControl Embedded Animation

    - by Matt B
    Hi all, I have a UserControl called Beetle.xaml which has animation makeing the legs move. So far so good. I added this to my Background.xaml page by decaring the xmlns and xaml as: xmlns:my="clr-namespace:Intellident.Liber8.GUI.Theme.Jungle" and <my:Beetle VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="180,0,0,175"> <UserControl.RenderTransform> <MatrixTransform x:Name="trnBeetle" /> </UserControl.RenderTransform> </my:Beetle> However I get errors telling me that I can't declare my:Name as I'm in the wrong scope. I can't declare my:Name as this doesn't exist. How do I do this, I want to create a path animation on the beetle to make him walk around... Ta, Matt. EDIT: THought I'd point out that both Beetle.xaml and Background.xaml live in Intellident.Liber8.GUI.Theme.Jungle namescope.

    Read the article

  • Android use of an string array on another method

    - by spagi
    Hi all. Im trying to make an activity that has a multiple choice dialog after you push a button. In there you select from a list of things. But these things are received from a web method before the dialog appears. So I create a string array after I receive them inside the onCreate to initialise it there with the correct size. But my dialog method then cant get the array because propably its out of its scope. My code looks like this @Override protected Dialog onCreateDialog(int id) //Here is where the array is loaded to the multiple select dialog etc @Override public void onCreate(Bundle savedInstanceState) //Here is where i initialise the array and get its contents etc I cant initialise my array when the class starts because I dont know its size yet. This has to do something with the scopes of my variables and I am pretty confused

    Read the article

  • JavaScript's Associative Array / Object can't be read in functions

    - by Matrym
    At the very beginning of the javascript file, I have: var lbp = {}; lbp.defaults = { minLength: 40 }; I can successfully alert it afterwards, with: alert(lbp.defaults.minLength); But as soon as I put it inside a function, when I alert, I get "Undefined". What gives, and how do I avoid this? Is it absolutely necessary to pass this variable into each function, for example, by doing: function(lbp) { alert(lbp.defaults.minLength); } I would have thought that defining it first, it would attain global scope and not be required to be passed in? Thanks in advance for enlightening me :)

    Read the article

  • When to rewrite vs. upgrade?

    - by MrGumbe
    All custom legacy software needs changing, or so say our users. Sometimes they want a feature or two added and all that is necessary to change a bit of code, add a control, or some other minor upgrade task. Sometimes they want to ditch their error-prone VB5 desktop solution and rewrite the whole thing as a rich Web 2.0 ASP.NET MVC application. More often, however, the scope of changes to legacy functionality lies somewhere between these two extremes. What rules of thumb to you use to decide whether you should upgrade an existing application or start from scratch?

    Read the article

  • how to access method variables from within an anonomous function in javascript

    - by Hussain
    I'm writing a small ajax class for personal use. In the class, I have a "post" method for sending post requests. The post method has a callback parameter. In the onreadystatechange propperty, I need to call the callback method. Something like this: this.requestObject.onreadystatechange = function() { callback(this.responseText); } However, I can't access the callback variable from within the anonomous function. How can I bring the callback variable into the scope of the onreadystatechange anonomous function?

    Read the article

  • ViewState Vs Session ... maintaining object through page lifecycle

    - by Kyle
    Can someone please explain the difference between ViewState and Session? More specifically, I'd like to know the best way to keep an object available (continuously setting members through postbacks) throughout the lifecycle of my page. I currently use Sessions to do this, but I'm not sure if it's the best way. For example: SearchObject searchObject; protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { searchObject = new SearchObject(); Session["searchObject"] = searchObject; } else { searchObject = (SearchObject)Session["searchObject"]; } } that allows me to use my searchObject anywhere else on my page but it's kind of cumbersome as I have to reset my session var if I change any properties etc. I'm thinking there must be a better way to do this so that .NET doesn't re-instantiate the object each time the page loads, but also puts it in the global scope of the Page class? Please advise. TIA

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >