instance

How to use FacesContext.getCurrentInstance(), it returns null

心不动则不痛 提交于 2020-01-12 14:08:35
问题 I've been struggling for the last couple of days with the login part of my web app. I've gotten to the point where I can succesfully authenticate a user using the JDBCRealm on tomcat(by reading users from a sql server database). Now I want to send some kind of feedback when the user's account has been blocked, or when the credentials are incorrect, this is where I'm stuck now. I wanted to use this: try { request.login(request.getParameter("user"), request.getParameter("pass")); } catch

How to implement “equals” method for generics using “instanceof”?

人走茶凉 提交于 2020-01-11 16:36:04
问题 I have a class that accepts a generic type , and I want to override the equals method in a non-awkward way (i.e. something that looks clean and has minimal amount of code, but for a very general use case). Right now I have something like this: public class SingularNode<T> { private T value; @SuppressWarnings("unchecked") @Override public boolean equals(Object other){ if(other instanceof SingularNode<?>){ if(((SingularNode<T>)other).value.equals(value)){ return true; } } return false; } }

Creating an instance of the Fractional Typeclass in Haskell

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-10 05:23:29
问题 I am a self-taught Haskell enthusiast and I was building a new type called Physical which I could use to represent physical quantities. It uses two Float s representing the value of the physical quantity and its uncertainty respectively. data Physical = Physical { value :: Float, err :: Float } I used standard rules for the uncertainty of a sum, difference and a product of two quantities to define an instance of the Num typeclass. instance Num Physical where (Physical v1 u1) + (Physical v2 u2

Create an instance of a React class from a string

折月煮酒 提交于 2020-01-10 02:28:30
问题 I have a string which contains a name of the Class (this is coming from a json file). This string tells my Template Class which layout / template to use for the data (also in json). The issue is my layout is not displaying. Home.jsx: //a template or layout. var Home = React.createClass({ render () { return ( <div>Home layout</div> ) } }); Template.jsx: var Template = React.createClass({ render: function() { var Tag = this.props.template; //this is the name of the class eg. 'Home' return (

Changing fill color of MovieClip Actionscript 3

﹥>﹥吖頭↗ 提交于 2020-01-09 10:28:50
问题 i want to ask, how to change only fill color of an instance on the stage - i can do it by using ColorTransform object, but it changes color of the whole instance, not just the fill. I want to change only the fill color, not the stroke color. can anybody help me? this is my code: function paint(){ var myColorTransform:ColorTransform = new ColorTransform(); myColorTransform.color = someColorNumber; coloredObject.transform.colorTransform = myColorTransform; } 回答1: This cant be done once you've

Is it OK/possible to modify instance variables inside an enum declaration?

余生颓废 提交于 2020-01-06 12:42:42
问题 Or, to re-phrase it: can enum types be "mutable"? public enum Foo { ONE,TWO; private String bar; Foo() { this.bar = ""; } String bar() { return bar; } // legal? void bar(String bar) { this.bar = bar; } } I guess if I want to modify it, it's no longer an enum type. Thoughts? 回答1: It's absolutely valid. It's just a really bad idea. Callers are likely to expect the enum to be properly immutable. In some cases you might want to make it "appear" to be immutable, e.g. with caching, while still

Displaying the “libraried” instances of prediefined strings within a file in CMD

半城伤御伤魂 提交于 2020-01-06 06:37:08
问题 All commands must be performed in Windows Command Prompt I have a file data.txt which has several strings in it: gargonxx**stringX**moregargon gargonargongargongargon gargon**stringZ**xxgargonxxxx and for this data file, I want to create a "library" file: stringX = informationx stringY = informationy stringZ = informationz then create variables in CMD out of the "information" shown in the "library" file, ONLY of the instances in the data.txt file that match with the library file. varx =

How do you dynamically generate classes from a list?

怎甘沉沦 提交于 2020-01-06 04:36:26
问题 I want to create a class that automatically adds a holder for values that I can access in the future so that when I run cd.orders or cd.users it will return or give me a dataframe of each of the tables I just queried against. Heres my sample code: class samplecode: def __init__(self,credentials): c = credentials ('DATABASE', 'USER', 'PASSWORD', 'HOST', 'PORT', 'SCHEMA') print('credentials loaded') self.connection_string = "postgresql://%s:%s@%s:%s/%s" % (c.USER, c.PASSWORD, c.HOST, str(c.PORT

C# Let multiple class share the same instance of another class

巧了我就是萌 提交于 2020-01-06 02:25:28
问题 Is there any way to let multiple class share the same instance of another class? So in my c# program i've got three class Gamelogic(A), FPSController(B), and SpawnPlayer(C). In my case class B and C would use and alter some variables in A, in order to use the variables i'm currently instantiating A in two different classes and then use dot notation to access the variable from the instance of A, but the problem is that after A instantiated in different classes, the change in instance.variable

AS3 dynamically attach MovieClip from a library to the Stage

强颜欢笑 提交于 2020-01-05 19:36:52
问题 I really have searched high and wide and i'm starting to think it may be my terminology that is preventing me from finding the answer. I have a MovieClip in my library set to Export to ActionScript 3.0 with a Class called 'Info_Win' (its basically going to be a pop-up window, the contents of which depends on it's instance name). I will be adding a given number of these MovieClips to the main stage and each one has to be given a custom instance name that will allow me to access it once it's on