actionevent

search for more blogs here

 

"Java experts! I call on thee!" posted by ~Ray
Posted on 2008-11-13 12:24:27

So anyways. I have been assigned to create a basic D&D game for my Java class. I have four classes set up: An armor class weapon class character class and the form: NewJFrameI am attempting to pass a variable from the form class (selectedIndex of a combo box) so that I can pick weapons/armor from an armory and then have the code execute (battle take place) based on the weapons/armor selected. I have basically everything set up already except for the ability to pass variables from the form to the armor/weapon classes. In this case it looks like the "armor" is extending (also called inheriting) "NewJFrame" so try just referencing base setSelArmor instead. I'm not sure if the "base" or "this" keyword is valid in Java but in C#. "this" gives you access to the members of the current instantiation of whatever object you're working in and "base" gives you access to the members of the base class of the object. Also. I don't think its really necessary to inherit a form class for "armor".. you'd be better off creating a base "avatar" class and then creating armor mage whatever else as data object classes and then have your form class just be solely for your UI. Hit me up on IM if you want to talk... DreamThrall on AIM or on MSN. I love helping people out learning this stuff. edit:scratch that it appears you have a very different problem you're trying to access variables from the parent this can only be done by passing an instance of the parent into the constructor of the class because the variable is only defined at run time and even then you wont be able to access the variable because its not public or in the global scope im not really sure why the armor class extends from the jframe class arent you just using an object to keep track of the armor the player has chosen? if thats so then you should just create an instance of the armor class within the frame class and then manipulate the object inside the actionperformed method if you need more help mail me your code. Date Time From To Message 11/17/2007 11:42:32 AM Garry Daniel Schaffer Hi there! 11/17/2007 11:42:35 AM Daniel Schaffer Garry I am currently away from the computer. 11/17/2007 12:34:08 PM Daniel Schaffer Garry hey 11/17/2007 12:34:21 PM Garry Daniel Schaffer hi there! 11/17/2007 12:34:31 PM Garry Daniel Schaffer I'm the guy with the java issues from HL2 net 11/17/2007 12:34:33 PM Daniel Schaffer Garry right 11/17/2007 12:34:37 PM Daniel Schaffer Garry you get that stuff figured out? 11/17/2007 12:34:53 PM Garry Daniel Schaffer no. I didn't get much of a chance to work on it last night - birthday party for my brother in law 11/17/2007 12:34:59 PM Daniel Schaffer Garry ah 11/17/2007 12:35:21 PM Daniel Schaffer Garry so are they teaching you oop fundamentals in that class before they throw the actual language at you? 11/17/2007 12:35:33 PM Garry Daniel Schaffer yea kind of 11/17/2007 12:35:59 PM Daniel Schaffer Garry honestly i have no idea how this stuff is taught.. i just learned from books 11/17/2007 12:36:08 PM Garry Daniel Schaffer ah right on 11/17/2007 12:36:23 PM Daniel Schaffer Garry its pretty easy once you get the hang of it though 11/17/2007 12:36:34 PM Garry Daniel Schaffer Well. I took VB last year and PHP this year as well. I have some basic programming knowledge but the OOP thing is screwing me I'd say 11/17/2007 12:36:51 PM Daniel Schaffer Garry heh yeah that can be a tough one to get your head around 11/17/2007 12:37:13 PM Daniel Schaffer Garry i can try to explain some stuff if you've got any questions 11/17/2007 12:37:44 PM Garry Daniel Schaffer I just need to be able to pass a variable from my JFrame class to another class based on what the user does in the JFrame 11/17/2007 12:38:07 PM Daniel Schaffer Garry do you have a mic? 11/17/2007 12:38:09 PM Garry Daniel Schaffer I don't quite see how instantiating a new JFrame class would work either 11/17/2007 12:38:12 PM Garry Daniel Schaffer nope 11/17/2007 12:38:20 PM Daniel Schaffer Garry that's not actually what you want to do 11/17/2007 12:38:23 PM Garry Daniel Schaffer errr 11/17/2007 12:38:25 PM Garry Daniel Schaffer object. I guess 11/17/2007 12:38:31 PM Daniel Schaffer Garry instantiating anew object i mean 11/17/2007 12:38:52 PM Daniel Schaffer Garry alright.. based on what i read in your post you should have a couple different classes 11/17/2007 12:39:26 PM Daniel Schaffer Garry you should have one for your UI form - I'm guessing this is JFrame that's where you have your dropdown boxes and other controls 11/17/2007 12:39:35 PM Garry Daniel Schaffer yep! 11/17/2007 12:39:38 PM Daniel Schaffer Garry oka 11/17/2007 12:39:39 PM Daniel Schaffer Garry y 11/17/2007 12:39:57 PM Daniel Schaffer Garry then i would also have a "base" class for avatars 11/17/2007 12:40:14 PM Daniel Schaffer Garry call "Avatar" or "AvatarBase" or whatever 11/17/2007 12:40:42 PM Garry Daniel Schaffer ok 11/17/2007 12:40:55 PM Daniel Schaffer Garry it'll have methods and properties used for performing the combat calculations and such 11/17/2007 12:41:06 PM Daniel Schaffer Garry but that's getting ahead a bit i think heh 11/17/2007 12:41:31 PM Daniel Schaffer Garry now what i believe you need to do for when someone selects something on your form is use event handlers 11/17/2007 12:41:57 PM Garry Daniel Schaffer "private void jComboBox2ActionPerformed(java awt event. ActionEvent evt)" 11/17/2007 12:42:13 PM Daniel Schaffer Garry okay so that fires when someone selects something? 11/17/2007 12:42:29 PM Garry Daniel Schaffer yep 11/17/2007 12:42:32 PM Daniel Schaffer Garry good 11/17/2007 12:42:55 PM Daniel Schaffer Garry alright so when that event fires its still in the context of the JFrame object 11/17/2007 12:43:00 PM Garry Daniel Schaffer yea 11/17/2007 12:43:17 PM Daniel Schaffer Garry so you should have access to the control itself as well as the other controls that are on the form 11/17/2007 12:43:43 PM Garry Daniel Schaffer yep. I think so 11/17/2007 12:43:56 PM Garry Daniel Schaffer that sounds about right 11/17/2007 12:45:08 PM Daniel Schaffer Garry okay so then you should be able to do something like int selectedIndex = jComboBox2 selectedIndex (or whatever the property name is) 11/17/2007 12:45:13 PM Daniel Schaffer Garry ; 11/17/2007 12:45:25 PM Garry Daniel Schaffer that's what I have yea 11/17/2007 12:45:49 PM Garry Daniel Schaffer but I need to get that variable into another class 11/17/2007 12:46:04 PM Daniel Schaffer Garry okay what class? 11/17/2007 12:46:08 PM Garry Daniel Schaffer armor class 11/17/2007 12:46:16 PM Daniel Schaffer Garry what's that do? 11/17/2007 12:46:34 PM Garry Daniel Schaffer defines what armor the character has on when the battle begins 11/17/2007 12:46:55 PM Garry Daniel Schaffer well it sets the armor value of the armor instance. I guess 11/17/2007 12:47:04 PM Daniel Schaffer Garry okay to clarify.. you have a class for armor that might have properties like absorption etc 11/17/2007 12:47:37 PM Daniel Schaffer Garry you could also have an array property that defines weapon types the armor is effective against 11/17/2007 12:47:49 PM Garry Daniel Schaffer yea but I'm not going that deep 11/17/2007 12:47:51 PM Daniel Schaffer Garry ah ok 11/17/2007 12:48:06 PM Daniel Schaffer Garry well to do what you're trying to do i would use an instantiator 11/17/2007 12:48:06 PM Garry Daniel Schaffer just if the user selects an armor from the drop down it is defined in the armor class 11/17/2007 12:48:10 PM Garry Daniel Schaffer ok 11/17/2007 12:48:21 PM Garry Daniel Schaffer JFrame frame= new JFrame(); int armPicked=frame setSelArmor(); ? 11/17/2007 12:48:31 PM Daniel Schaffer Garry oops i meant constructor 11/17/2007 12:48:48 PM Daniel Schaffer Garry in your armor class you define a contructor that will take the value of the armor 11/17/2007 12:49:05 PM Daniel Schaffer Garry so in armor you might have a property called value 11/17/2007 12:49:37 PM Daniel Schaffer Garry so then you define the constructor like this: public amor(int value) this value = value; 11/17/2007 12:49:47 PM Daniel Schaffer Garry oops the im client took out the brackets 11/17/2007 12:49:57 PM Daniel Schaffer Garry public armor(int value) { 11/17/2007 12:50:03 PM Daniel Schaffer Garry this value = value; } 11/17/2007 12:50:41 PM Daniel Schaffer Garry and then when you create your armor object on the form: armor theArmor = new armor(jComboBox2 selectedValue); 11/17/2007 12:51:10 PM Daniel Schaffer Garry keep in mind that I don't *actually* know java syntax so the code I'm typing is just an approximation 11/17/2007 12:51:32 PM Garry Daniel Schaffer hmm ok 11/17/2007 12:52:10 PM Daniel Schaffer Garry heh are you lost? 11/17/2007 12:52:51 PM Garry Daniel Schaffer Not exactly but doing all of that might be a little tough because I basically already have it done. I just need the form to pass a variable but it's proving difficult and painful 11/17/2007 12:53:12 PM Daniel Schaffer Garry okay so you've already written your armor class? 11/17/2007 12:53:21 PM Garry Daniel Schaffer everything basically 11/17/2007 12:53:38 PM Daniel Schaffer Garry okay so what properties does the armor class have? 11/17/2007 12:53:51 PM Daniel Schaffer Garry actually 11/17/2007 12:53:59 PM Garry Daniel Schaffer well it returns a value is what it does 11/17/2007 12:54:01 PM Daniel Schaffer Garry what property of the armor class are you trying to set by passing the variable to it? 11/17/2007 12:54:06 PM Daniel Schaffer Garry oh 11/17/2007 12:54:11 PM Daniel Schaffer Garry so its a method then not a class? 11/17/2007 12:54:47 PM Garry Daniel Schaffer kind of. I guess 11/17/2007 12:55:07 PM Garry Daniel Schaffer it returns a value and then in the character class 11/17/2007 12:55:08 PM Garry Daniel Schaffer I have 11/17/2007 12:55:12 PM Garry Daniel Schaffer arm = new armor(); 11/17/2007 12:55:15 PM Garry Daniel Schaffer and then: 11/17/2007 12:55:30 PM Daniel Schaffer Garry heh do you think you could email me what you've got? 11/17/2007 12:55:37 PM Garry Daniel Schaffer might be a good idea 11/17/2007 12:55:41 PM Daniel Schaffer Garry 11/17/2007 12:56:16 PM Daniel Schaffer Garry take a look through this: 11/17/2007 12:58:27 PM Garry Daniel Schaffer let me log onto MSN on my laptop brb DateTimeFromToMessage11/17/20071:00:43 PMGarry sends C:\Documents and Settings\Garry\Desktop\D&D-Java txt11/17/20071:00:59 PMGarryDaniel Schafferif it's commented out chances are it was something I tried that didn't work11/17/20071:01:05 PMTransfer of "D&D-Java txt" is complete.11/17/20071:01:09 PMDaniel SchafferGarryah11/17/20071:01:24 PMGarryDaniel Schafferwhat it does now is loads the form and does the battle immediately in system out11/17/20071:01:24 PMDaniel SchafferGarryyou generally just want to delete that stuff 11/17/20071:01:40 PMGarryDaniel Schafferwell it might give you an idea of what I tried that didn't work / what my thought process is11/17/20071:01:47 PMDaniel SchafferGarryah ok11/17/20071:02:02 PMGarryDaniel SchafferI don't care about how it conducts the battle at the moment. I just need to pass variables from the form to the armor class11/17/20071:02:11 PMGarryDaniel SchafferI don't care how I do it as long as it gets done11/17/20071:02:31 PMGarryDaniel SchafferI guess I need to pass variables to the weapon class too since I have two combo boxes but if I get one done i should be able to get the other done as well11/17/20071:02:43 PMGarryDaniel Schafferbrb feel free to ask any questions and I'll answer them when I get back11/17/20071:02:51 PMDaniel SchafferGarryokay so why does armor extend NewJFrame?11/17/20071:03:56 PMDaniel SchafferGarryokay i think i'm starting to understand...11/17/20071:04:14 PMDaniel SchafferGarryyou have a form class where you select each attribute of your character11/17/20071:07:11 PMDaniel SchafferGarryer no11/17/20071:08:40 PMGarryDaniel Schafferthe form class is just for loading the form pretty much11/17/20071:08:48 PMGarryDaniel Schaffermaybe that's a better way to do that...11/17/20071:09:02 PMGarryDaniel SchafferI guess I could just load the form from the other classes in a constructor?11/17/20071:09:04 PMDaniel SchafferGarryalright well for now why does armor extend NewJFrame?11/17/20071:09:20 PMGarryDaniel SchafferI guess that was something that I just tried because I thought it might work11/17/20071:09:35 PMGarryDaniel SchafferI don't even really know what that does11/17/20071:09:57 PMDaniel SchafferGarryokay.. you understand superclasses and inheritance?11/17/20071:10:04 PMGarryDaniel Schaffervageuly11/17/20071:10:12 PMGarryDaniel Schaffererr spelling but you get it11/17/20071:10:15 PMDaniel SchafferGarryheh right 11/17/20071:10:28 PMDaniel SchafferGarryokay.. do you understand the difference between a class and an object?11/17/20071:10:51 PMGarryDaniel SchafferOur teacher explains it as a car analogy11/17/20071:11:07 PMGarryDaniel SchafferThere's no such thing as a car object.11/17/20071:11:07 PMDaniel SchafferGarryright vehicle truck motorcycle etc11/17/20071:11:16 PMGarryDaniel SchafferThere's a car class11/17/20071:11:17 PMGarryDaniel SchafferI guess11/17/20071:11:27 PMDaniel SchafferGarryokay but that's not the same question11/17/20071:11:53 PMDaniel SchafferGarrya class is like a definiton while an object is an instantiation of a class11/17/20071:12:05 PMGarryDaniel Schafferright!11/17/20071:12:23 PMGarryDaniel SchafferI'm starting to understand this stuff a little better11/17/20071:12:41 PMDaniel SchafferGarryokay so when you extend the NewJFrame class it doesn't actually do anything because your object (in this case your form) is of the NewJFrame class11/17/20071:13:16 PMDaniel SchafferGarryin order for it to do anything you'd have to instantiate a new armor class which in this case would mean opening up a new form11/17/20071:14:12 PMDaniel SchafferGarrynow i think all you need to do is move the methods from armor into your NewJFrame class11/17/20071:15:03 PMGarryDaniel Schaffercould I do like11/17/20071:15:15 PMGarryDaniel Schafferarm = new armor(); or...11/17/20071:15:26 PMGarryDaniel Schafferwell no. I don' think that would work11/17/20071:15:31 PMGarryDaniel Schafferat least not serve the purpose11/17/20071:15:36 PMDaniel SchafferGarryright11/17/20071:15:59 PMDaniel SchafferGarryall you're trying to do is just get an integer that represents the value of the armor right?11/17/20071:16:03 PMGarryDaniel Schafferyea11/17/20071:16:13 PMDaniel SchafferGarryokay so you don't really need an entirely separate class for that11/17/20071:16:42 PMDaniel SchafferGarryunless that's part of the assignment11/17/20071:16:52 PMGarryDaniel Schafferhaha yea. I think that it is11/17/20071:16:56 PMDaniel SchafferGarrylol ok11/17/20071:17:05 PMDaniel SchafferGarryalright well let's try and restructure your classes then11/17/20071:17:23 PMDaniel SchafferGarryyou kinda did weapon the right way11/17/20071:17:53 PMGarryDaniel Schafferdoesn't seem any different than armor11/17/20071:17:56 PMDaniel SchafferGarryfor armor what I would do is define a "Value" property11/17/20071:18:12 PMDaniel SchafferGarryremove the extends NewJFrame11/17/20071:18:15 PMGarryDaniel Schafferdone11/17/20071:18:19 PMDaniel SchafferGarryarmor shouldn't extend anything11/17/20071:18:27 PMDaniel SchafferGarryso you'd have your Value property which is an int11/17/20071:18:40 PMGarryDaniel Schafferwhat about my arm variable?11/17/20071:18:47 PMGarryDaniel Schafferthat's my armor value I am returning11/17/20071:18:47 PMDaniel SchafferGarryhold on 11/17/20071:19:03 PMDaniel SchafferGarrydo you understand constructors?11/17/20071:19:16 PMGarryDaniel Schafferthey seem to be the thing that executes stuff11/17/20071:19:26 PMDaniel SchafferGarrykinda sorta not really11/17/20071:19:35 PMDaniel SchafferGarrya constructor is the method that instantiates a class11/17/20071:19:47 PMDaniel SchafferGarrythey don't have a return type and they can accept parameters11/17/20071:20:08 PMDaniel SchafferGarryin fact when you do weap = new weapon();11/17/20071:20:19 PMDaniel SchafferGarrythat's using a constructor - the default constructor11/17/20071:20:42 PMGarryDaniel Schafferah11/17/20071:21:09 PMDaniel SchafferGarryso what i think you should do is create a constructor for the armor class that accepts the cType variable11/17/20071:21:35 PMDaniel SchafferGarryexcept i'd call it something more descriptive11/17/20071:22:10 PMGarryDaniel Schafferthat's just the character type11/17/20071:22:12 PMGarryDaniel Schaffersoldier or creature11/17/20071:22:22 PMDaniel SchafferGarryokay11/17/20071:23:00 PMDaniel SchafferGarryso have a CharacterType property that is a char11/17/20071:23:41 PMDaniel SchafferGarryyour constrcutor would then look like this: public armor(Char cType) { this setCharacterType(cType); }11/17/20071:24:04 PMDaniel SchafferGarry(i think that's the right java syntax for a property set accessor?)11/17/20071:24:18 PMGarryDaniel Schaffernot sure11/17/20071:25:06 PMDaniel SchafferGarrylooking at the rest of your code it looks like it is11/17/20071:25:26 PMDaniel SchafferGarryso then the get accessor for your Value property would actually do all the wokr11/17/20071:25:27 PMDaniel SchafferGarrywork **11/17/20071:26:09 PMDaniel SchafferGarryso instead of int calcAmr(char cType) you'd have: int getValue()11/17/20071:26:23 PMDaniel SchafferGarryyou follow me?11/17/20071:26:47 PMGarryDaniel Schaffertrying to but not exactly11/17/20071:27:02 PMDaniel SchafferGarryokay what are you foggy on?11/17/20071:27:35 PMGarryDaniel Schafferjust not really sure why that would do anything11/17/20071:27:43 PMGarryDaniel Schafferthe setCharacterType(cType) etc.11/17/20071:28:18 PMDaniel SchafferGarrywell you'd have to change your code to use that property instead of getting it from the method parameter11/17/20071:29:28 PMGarryDaniel Schafferhmm11/17/20071:30:20 PMGarryDaniel SchafferI'm missing visual basic at this point11/17/20071:30:26 PMGarryDaniel Schafferhaha 11/17/20071:30:42 PMDaniel SchafferGarryso you'd have this: public class Armor { private char characterType; public Armor(char cType){ this characterType = cType; } public int getValue() { // do all your calcArm work here instead }11/17/20071:30:44 PMDaniel SchafferGarry}11/17/20071:31:19 PMGarryDaniel Schafferok11/17/20071:31:27 PMDaniel SchafferGarrythen from your form you call: Armor armor = new Armor(cType);11/17/20071:31:37 PMGarryDaniel Schafferhmm...11/17/20071:32:07 PMDaniel SchafferGarrycloser now?11/17/20071:32:49 PMGarryDaniel Schafferyea I think so11/17/20071:33:14 PMDaniel SchafferGarrynow you have a real reason for having separate classes11/17/20071:33:38 PMDaniel SchafferGarrybecause having a completely separate class for a single method is frankly a bit silly 11/17/20071:34:22 PMDaniel SchafferGarrynow are you also supposed to be demonstrating superclasses?11/17/20071:35:58 PMGarryDaniel Schaffertyping this out now one sec11/17/20071:36:05 PMDaniel SchafferGarryk11/17/20071:37:17 PMGarryDaniel Schafferoh and no i don't think superclasses is an issue11/17/20071:37:38 PMDaniel SchafferGarryokay we don't have to go there then.. unless you really want to impress teacher 11/17/20071:38:06 PMGarryDaniel Schafferso when I type out11/17/20071:38:11 PMGarryDaniel Schafferpublic Armor(char cType){ this characterType = cType; }11/17/20071:38:17 PMGarryDaniel SchafferIt stays "return type required"11/17/20071:38:40 PMDaniel SchafferGarryokay is your class named armor or Armor?11/17/20071:38:58 PMDaniel SchafferGarrythe naming convention is to capitalize the first letter of class names11/17/20071:39:11 PMGarryDaniel Schafferdamn you11/17/20071:39:16 PMGarryDaniel Schafferthat was it11/17/20071:39:18 PMDaniel SchafferGarry 11/17/20071:41:43 PMDaniel SchafferGarrynow the interest of keeping things uniform you should follow the same pattern for your Weapon class11/17/20071:42:06 PMDaniel SchafferGarryuse the constructor that takes the cType parameter11/17/20071:43:53 PMDaniel SchafferGarrynow for calcDamage what does "stunned" do?11/17/20071:44:10 PMGarryDaniel Schafferoh yea. I haven't really implemented that11/17/20071:44:13 PMDaniel SchafferGarryokay11/17/20071:44:18 PMGarryDaniel Schafferit's a % chance to miss a turn11/17/20071:44:31 PMDaniel SchafferGarrythat's what I thought.. you'll probably need to use an out paramter for that11/17/20071:45:05 PMDaniel SchafferGarryso it'd be like: int CalculateDamage(out boolean stunned) { ... }11/17/20071:45:57 PMDaniel SchafferGarryand then when you call it: boolean stunned; int dmg = weap. CalculateDamage(out stunned);11/17/20071:46:47 PMDaniel SchafferGarryif(stunned) { System out println("You wimp! You got stunned and miss a turn!"); }11/17/20071:47:02 PMGarryDaniel Schafferhah yea11/17/20071:47:52 PMDaniel SchafferGarryalthough.. you probably need to have "stunned" be a property of weapon11/17/20071:48:01 PMDaniel SchafferGarryso that way it'll be propegated to the next round11/17/20071:48:32 PMDaniel SchafferGarrythen in CalculateDamage you'll be able to check if the player is stunned from the previous round 11/17/20071:49:06 PMDaniel SchafferGarryeek11/17/20071:49:07 PMDaniel SchafferGarryok11/17/20071:49:42 PMDaniel SchafferGarrywhere are you now?11/17/20071:49:50 PMGarryDaniel SchafferI appreciate your help but I might need to tackle this a different way if possible11/17/20071:50:31 PMDaniel SchafferGarrywell maybe i can try explaining a little more instead of throwing code at you :\ sorry i get a little overzealous with programming11/17/20071:50:39 PMGarryDaniel Schafferhaha no it's fine11/17/20071:51:13 PMGarryDaniel SchafferI just want to cheat and do it the way we were discussing earlier11/17/20071:51:19 PMGarryDaniel Schafferget rid of the armor and weapon class11/17/20071:51:29 PMDaniel SchafferGarryheh ok11/17/20071:51:36 PMGarryDaniel Schaffererr I meant11/17/20071:51:40 PMGarryDaniel Schaffer"I'm tempting to...."11/17/20071:51:50 PMGarryDaniel SchafferI don't know if I should actually do that11/17/20071:51:53 PMDaniel SchafferGarryah11/17/20071:52:05 PMDaniel SchafferGarrywell does the assignment say you're supposed to use multiple classes?11/17/20071:52:28 PMGarryDaniel Schafferyea I believe so but I don't know if that's feasable at this point11/17/20071:52:36 PMDaniel SchafferGarrywell its certainly feasible11/17/20071:53:19 PMDaniel SchafferGarrylet's try this.. what don't you understand about the code i was explaining?11/17/20071:54:01 PMGarryDaniel Schafferwell when I tried to create a new instance of armor in my jframe it wasn't quite working11/17/20071:54:17 PMDaniel SchafferGarrywhat error did you get?11/17/20071:54:29 PMGarryDaniel Schafferlet me see one sec11/17/20071:56:59 PMGarryDaniel Schafferok one thing was my filename was "armor java"11/17/20071:57:08 PMGarryDaniel Schaffernot "Armor java" - I don't think it liked that very much11/17/20071:57:26 PMDaniel SchafferGarryhm.. okay11/17/20071:57:57 PMGarryDaniel Schaffernow where do I put "Armor armor = new Armor(cType);"11/17/20071:58:07 PMGarryDaniel Schafferin the NewJFrame constructor?11/17/20071:58:54 PMDaniel SchafferGarryit looks like it should go in the character class11/17/20071:59:15 PMDaniel SchafferGarry*cough* which should be Character *cough* 11/17/20072:00:13 PMGarryDaniel Schafferok.. well that's done I guess11/17/20072:02:14 PMDaniel SchafferGarryalright there's a couple things that don't match up here11/17/20072:02:29 PMGarryDaniel SchafferI'm sure there's more than that too 11/17/20072:02:37 PMDaniel SchafferGarryheh11/17/20072:02:45 PMDaniel SchafferGarrycharacter Soldier = new character (400. 50. 50. 15. 's'); character Creature = new character (700. 75. 75. 100. 'c');11/17/20072:03:03 PMDaniel SchafferGarryyou hard code the armor value there.. so what's the point of calcArmor?11/17/20072:03:21 PMGarryDaniel SchafferI guess I should have clarified this at the beginning11/17/20072:03:29 PMGarryDaniel SchafferBut I didn't expect to get this indepth with you11/17/20072:03:50 PMGarryDaniel SchafferThe idea of the game is that you're basically the soldier - you select the armor/weapons for the soldier and you fight the creature11/17/20072:03:51 PMDaniel SchafferGarryheh its cool11/17/20072:04:04 PMGarryDaniel Schafferthe Creature has a base value of 700 armor11/17/20072:04:14 PMDaniel SchafferGarrythat's 700 hp11/17/20072:04:17 PMGarryDaniel Schafferoops11/17/20072:04:22 PMDaniel SchafferGarryarmor is the 2nd to last parameter 11/17/20072:04:41 PMGarryDaniel Schafferbase armor of 100 plus a random int of 1-5011/17/20072:04:51 PMDaniel SchafferGarryokay so calcarmor is the random int11/17/20072:04:54 PMGarryDaniel Schafferbasically the idea is to get some randomness to the game as opposed to static boringness11/17/20072:04:57 PMDaniel SchafferGarryright11/17/20072:05:22 PMGarryDaniel Schafferso the creature always gets 100+(1-50)11/17/20072:05:45 PMGarryDaniel Schafferand the soldier gets 75+(armor type selected)11/17/20072:05:57 PMGarryDaniel Schaffereven the armor type selected has randomness though11/17/20072:06:06 PMDaniel SchafferGarryok11/17/20072:06:26 PMDaniel SchafferGarryi just don't see where the armor is taken into account at all though11/17/20072:07:25 PMDaniel SchafferGarryoh ok calcDefend11/17/20072:07:36 PMGarryDaniel Schafferyea11/17/20072:08:02 PMDaniel SchafferGarryOKAY11/17/20072:08:03 PMDaniel SchafferGarryheh11/17/20072:08:30 PMDaniel SchafferGarryso in the Character constructor change this: arm = new armor();11/17/20072:08:38 PMDaniel SchafferGarryto this: arm = new Armor(cType);11/17/20072:08:43 PMGarryDaniel Schafferahhhh11/17/20072:08:54 PMDaniel SchafferGarryand then in calcDefend()11/17/20072:09:12 PMDaniel SchafferGarryarm calcArm changes to arm. Value11/17/20072:09:24 PMGarryDaniel Schafferok11/17/20072:09:30 PMDaniel SchafferGarryor getValue() ...11/17/20072:09:42 PMDaniel SchafferGarryi'm not sure how java compiles properties11/17/20072:09:43 PMGarryDaniel Schafferno this cType ?11/17/20072:09:57 PMGarryDaniel Schafferyea need that11/17/20072:09:58 PMGarryDaniel Schaffernm11/17/20072:10:08 PMDaniel SchafferGarrynope because the Armor class already knows the cType because you passed it in as a parameter in the constructor11/17/20072:10:12 PMGarryDaniel Schafferoh ok11/17/20072:10:25 PMDaniel SchafferGarryclearer now?11/17/20072:10:45 PMGarryDaniel Schafferno it didn't like that11/17/20072:10:52 PMDaniel SchafferGarrywhat's the error?11/17/20072:11:41 PMGarry sends C:\Documents and Settings\Garry\Desktop\errorsinJavaD&D txt11/17/20072:11:52 PMTransfer of "errorsinJavaD&D txt" is complete.11/17/20072:12:35 PMDaniel SchafferGarryheh you need to change wherever you say "character" to "Character"11/17/20072:12:54 PMGarryDaniel SchafferI did11/17/20072:12:56 PMGarryDaniel SchafferI think11/17/20072:13:04 PMDaniel SchafferGarrycharacter Soldier = new character (400. 50. 50. 15. 's');11/17/20072:13:24 PMDaniel SchafferGarryi think you maybe need to rename the file too?11/17/20072:13:41 PMGarryDaniel Schafferdid that one sec11/17/20072:14:19 PMGarryDaniel Schafferok now it's just11/17/20072:14:39 PMGarry sends C:\Documents and Settings\Garry\Desktop\errorsinJavaD&D txt11/17/20072:14:52 PMTransfer of "errorsinJavaD&D txt" is complete.11/17/20072:15:17 PMGarryDaniel Schafferit ran when I put "return armor + this arm getValue(cType);"11/17/20072:15:25 PMGarryDaniel Schafferinstead of "return armor + this arm getValue();"11/17/20072:15:31 PMDaniel SchafferGarryreally?11/17/20072:15:38 PMDaniel SchafferGarrywhat's the signature of the getValue method look like?11/17/20072:16:00 PMGarryDaniel Schafferprivate char characterType; public Armor(char cType){ this characterType = cType; } public int getValue(char cType){11/17/20072:16:05 PMDaniel SchafferGarryah11/17/20072:16:17 PMDaniel SchafferGarryit should just look like this: public int getValue() { }11/17/20072:16:24 PMDaniel SchafferGarrywell with the code inside it of course11/17/20072:16:36 PMGarryDaniel Schaffer:$11/17/20072:16:48 PMDaniel SchafferGarrypublic int getValue()11/17/20072:16:53 PMGarryDaniel Schafferbut now...11/17/20072:16:56 PMDaniel SchafferGarry{ // all your code }11/17/20072:17:04 PMGarryDaniel Schafferit can't find the variable cType11/17/20072:17:12 PMGarryDaniel Schafferdo I need to define that as a public variable or something?11/17/20072:17:25 PMDaniel SchafferGarryreplace that with characterType;11/17/20072:17:42 PMGarryDaniel Schafferso11/17/20072:17:46 PMGarryDaniel Schafferif (cType == 's') {11/17/20072:17:54 PMGarryDaniel Schafferif (characterType == 's' {11/17/20072:17:54 PMGarryDaniel Schaffer?11/17/20072:17:56 PMDaniel SchafferGarryright11/17/20072:18:23 PMDaniel SchafferGarryremember characterType is a private member of Armor: private char characterType;11/17/20072:18:33 PMGarryDaniel Schafferyea I see11/17/20072:19:13 PMGarryDaniel Schafferappears to work!11/17/20072:19:17 PMDaniel SchafferGarryawesome11/17/20072:21:10 PMDaniel SchafferGarryhey why do you have all that stuff in main() ?11/17/20072:21:21 PMGarryDaniel Schafferwhere?11/17/20072:21:27 PMGarryDaniel Schafferin the form?11/17/20072:21:45 PMDaniel SchafferGarrypublic static void main(String args[]) { java awt. EventQueue invokeLater(new Runnable() { public void run() { new NewJFrame() setVisible(true); int X = 0; //character Soldier = new character(1000,40,20,40,'k');//instance a Soldier //character Creature = new character(1000,40,20,40,'d');//instance a Creature //character(int hp int stren int dex int armor,char cType) character Soldier = new character (400. 50. 50. 15. 's'); character Creature = new character (700. 75. 75. 100. 'c'); int turn = 0; int attack = 0; int defend = 0; int damage = 0; Random myRandom = new Random(); //make a random num gen11/17/20072:21:46 PMDaniel SchafferGarryetc11/17/20072:22:00 PMGarryDaniel SchafferI needed to put it somewhere 11/17/20072:22:02 PMDaniel SchafferGarrymain should just be used to launch the application11/17/20072:22:09 PMGarryDaniel Schafferyea. I know11/17/20072:22:12 PMDaniel SchafferGarryas it is that code will only run once11/17/20072:22:16 PMGarryDaniel Schafferwell. I DIDN'T know11/17/20072:22:19 PMDaniel SchafferGarryheh 11/17/20072:23:16 PMGarryDaniel Schafferwhere should I put it now?11/17/20072:23:30 PMDaniel SchafferGarrywell are you going to have the player click a button between each round or will it just go until someone's dead?11/17/20072:24:14 PMDaniel SchafferGarryi'd use a button.. otherwise you have to use a loop and then worry about accidentally creating an infinite loop etc11/17/20072:24:54 PMGarryDaniel Schafferhmm11/17/20072:25:01 PMDaniel SchafferGarrywell11/17/20072:25:03 PMGarryDaniel Schafferthe way it's set up now it just creates a loop11/17/20072:25:09 PMGarryDaniel Schafferand goes untl someone dies11/17/20072:25:16 PMGarryDaniel Schafferbut I'm tempted to change that and I probably will use the button11/17/20072:25:24 PMDaniel SchafferGarryyou could just do while(Solder getHp() > 0 && Creature getHp() > 0)11/17/20072:25:41 PMGarryDaniel SchafferI do. I think11/17/20072:26:00 PMDaniel SchafferGarryi'm not seeing how it loops11/17/20072:26:10 PMGarryDaniel Schafferwhile (Soldier getHp() > 0 && Soldier getHp() > 0){11/17/20072:26:23 PMGarryDaniel Schafferdid you copy that from my code?11/17/20072:26:25 PMDaniel SchafferGarryoh11/17/20072:26:27 PMDaniel SchafferGarryno lol11/17/20072:26:29 PMDaniel SchafferGarryi see it now11/17/20072:26:31 PMGarryDaniel Schafferhaha that's exactly what I have11/17/20072:26:34 PMDaniel SchafferGarryhaha11/17/20072:27:01 PMDaniel SchafferGarrywell i think that runs before the user ever does anything in the form though11/17/20072:27:10 PMGarryDaniel Schafferoh it does and I will have to change that11/17/20072:27:16 PMDaniel SchafferGarryalright11/17/20072:27:23 PMGarryDaniel SchafferBut first of all... I need to get the armor variable passed from the form11/17/20072:27:29 PMGarryDaniel Schafferwhich is how all this mess started11/17/20072:27:34 PMDaniel SchafferGarryhaha right11/17/20072:27:35 PMDaniel SchafferGarryokay11/17/20072:27:37 PMGarryDaniel Schafferand weapon variable too. I suppose11/17/20072:27:57 PMDaniel SchafferGarryokay so back to your event handler11/17/20072:28:09 PMDaniel SchafferGarryits in the NewJFrame class now right?11/17/20072:29:13 PMGarryDaniel Schafferyes11/17/20072:29:17 PMDaniel SchafferGarrygood11/17/20072:29:32 PMDaniel SchafferGarryok hold that though11/17/20072:29:33 PMDaniel SchafferGarryt11/17/20072:30:21 PMDaniel SchafferGarrybefore we do this you'll need to move all that code in main() to a different method in NewJFrame11/17/20072:30:38 PMDaniel SchafferGarryyou can call it something like DoCombat() or ExecuteCombat()11/17/20072:30:47 PMGarryDaniel Schafferok cool11/17/20072:30:50 PMDaniel SchafferGarryalso11/17/20072:31:35 PMDaniel SchafferGarryinstead of declaring and instantiating the Soldier and Creature variables in the method they should be members of NewJFrame11/17/20072:32:17 PMGarryDaniel Schafferoh yea ok11/17/20072:32:22 PMGarryDaniel Schafferso I would do like11/17/20072:32:26 PMGarryDaniel SchafferCharacter Soldier = new Character (400. 50. 50. 15. 's'); Character Creature = new Character (700. 75. 75. 100. 'c');11/17/20072:32:32 PMGarryDaniel Schafferinside of... the main method?11/17/20072:32:35 PMDaniel SchafferGarrywell don't instantiate them yet11/17/20072:32:43 PMDaniel SchafferGarryand no not in the main method11/17/20072:33:35 PMDaniel SchafferGarryyou should no longer be doing ANYTHING in the main method except this: java awt. EventQueue invokeLater(new Runnable() { public void run() { new NewJFrame() setVisible(true); int X = 0; // Variables declaration - do not modify private javax swing. JButton jButton1; private javax swing. JButton jButton2; private javax swing. JComboBox jComboBox1; private javax swing. JComboBox jComboBox2; private javax swing. JPanel jPanel1; private javax swing. JPanel jPanel2; private javax swing. JScrollPane jScrollPane1; private javax swing. JTextArea jTextArea1; private java awt. Label label1; // End of variables declaration11/17/20072:33:46 PMDaniel SchafferGarryi'm guessing all that code was autogenerated by your IDE?11/17/20072:33:54 PMGarryDaniel Schafferyea 11/17/20072:34:08 PMDaniel SchafferGarryok.. that all needs to stay everything else should go into your new combat method11/17/20072:35:33 PMGarryDaniel Schafferit's asking for a return type... so I would return the results of the battle yes?11/17/20072:35:51 PMDaniel SchafferGarrywell no.. it'll be void11/17/20072:35:59 PMDaniel SchafferGarryat least the way you have things set up now11/17/20072:36:07 PMGarryDaniel Schafferah genius11/17/20072:36:12 PMGarryDaniel Schafferyes that makes sense11/17/20072:36:33 PMGarryDaniel Schafferso where do I instantiate the characters?11/17/20072:37:02 PMDaniel SchafferGarryi would do it in the handler for the "enter battle" button11/17/20072:37:14 PMGarryDaniel Schafferah good idea11/17/20072:37:20 PMDaniel SchafferGarrybecause at that point the user will have selected both the armor and weapon types11/17/20072:37:23 PMGarryDaniel Schafferlet me set up that form11/17/20072:37:50 PMDaniel SchafferGarryi've actually got to go now wife is yelling at me to help clean the house11/17/20072:38:49 PMDaniel SchafferGarryas far as passing the armor and weapon types i'd add two more parameters to your Character class instantiator11/17/20072:39:25 PMDaniel SchafferGarrychar aType char wType11/17/20072:39:44 PMDaniel SchafferGarrythen you can pass those off to your Armor and Weapon classes11/17/20072:40:31 PMDaniel SchafferGarrygood luck.. i should be on later today if you've got more questions 11/17/200710:36:48 PMGarryDaniel Schafferhey you gonna be around tomorrow?11/18/200712:21:27 AMDaniel SchafferGarryyeah11/18/20071:11:43 PMGarryDaniel Schafferhey!11/18/20071:11:45 PMDaniel SchafferGarryI am currently away from the computer.11/18/20071:45:36 PMDaniel SchafferGarryhey what's up?11/18/20071:45:47 PMGarryDaniel Schafferissues11/18/20071:45:51 PMGarryDaniel Schafferseveral of them11/18/20071:46:10 PMGarryDaniel SchafferI have them typed up actually11/18/20071:46:35 PMGarryDaniel Schafferwell actually the main one I have an issue with isn't much - I just can't pass a variable from the form11/18/20071:46:44 PMGarryDaniel Schafferstill...11/18/20071:47:12 PMDaniel SchafferGarrycan't pass a variable from the form? what code are you using and what error?11/18/20071:48:27 PMGarryDaniel Schafferwell. I tried adding "setSelArmor setSelWeapon" to the Character instantiation like you suggested but that didn't work11/18/20071:49:09 PMGarryDaniel SchafferI'm tring to retrieve the variable from getSelectedIndex11/18/20071:49:11 PMGarryDaniel Schafferon the form11/18/20071:49:33 PMDaniel SchafferGarrywell those are set accessors11/18/20071:52:02 PMGarryDaniel SchafferI just don't know how I can get a variable from something someone does on the form11/18/20071:52:35 PMDaniel SchafferGarryhm and that doesn't work?11/18/20071:52:57 PMGarryDaniel Schafferwell I mean it does within the context of the ActionPerformed event or whatever11/18/20071:53:01 PMDaniel SchafferGarryokay11/18/20071:53:02 PMGarryDaniel SchafferBut I can't get that outside of it11/18/20071:53:15 PMGarryDaniel SchafferTo another class or even outside of that event at all even in the same class11/18/20071:53:32 PMDaniel SchafferGarryokay11/18/20071:53:52 PMDaniel SchafferGarrydoes the ActionEvent object have a "sender" property or something like that?11/18/20071:54:05 PMDaniel SchafferGarrysomething that would give you a reference to the object that caused the event?11/18/20071:54:29 PMGarryDaniel Schafferprivate void jComboBox2ActionPerformed(java awt event. ActionEvent evt) {11/18/20071:54:30 PMDaniel SchafferGarryi guess this is where java differs from C# and WinForms a bit11/18/20071:54:43 PMDaniel SchafferGarryyeah what properties does the ActionEvent class have'11/18/20071:55:27 PMGarryDaniel SchafferjComboBox1 setModel(new javax swing. DefaultComboBoxModel(new String[] { "Select Weapon...". "Photon Pistol". "Freeze Ray". "Plasma Grenade Launcher" })); jComboBox1 setEnabled(false); jComboBox1 addActionListener(new java awt event. ActionListener() { public void actionPerformed(java awt event. ActionEvent evt) { jComboBox1ActionPerformed(evt);11/18/20071:55:28 PMGarryDaniel Schaffer?11/18/20071:55:31 PMGarryDaniel SchafferO11/18/20071:55:32 PMGarryDaniel Schaffer:-O11/18/20071:55:53 PMDaniel SchafferGarrythat's not what i mean11/18/20071:56:13 PMDaniel SchafferGarryyour event handler method takes an ActionClass object as a parameter11/18/20071:56:17 PMDaniel SchafferGarrywhat data is in that object?11/18/20071:57:23 PMGarryDaniel SchafferNot quite sure what you mean11/18/20071:57:31 PMDaniel SchafferGarryoh ok11/18/20071:57:52 PMDaniel SchafferGarryyou can get the object that fired the event from the getSource() method11/18/20071:58:21 PMDaniel SchafferGarryso try adding this in your even handler:11/18/20071:58:37 PMDaniel SchafferGarryjavax swing. JComboBox sender = (javax swing. JComboBox)evt getSource();11/18/20071:59:10 PMGarryDaniel Schafferno errors.. that's good11/18/20071:59:19 PMDaniel SchafferGarryokay that should give you a good reference to the combo box that fired the event11/18/20072:00:07 PMGarryDaniel Schafferso how do I reference that?11/18/20072:00:28 PMDaniel SchafferGarryokay do you understand what i did in the code i sent you?11/18/20072:00:34 PMGarryDaniel Schaffernot 100%11/18/20072:00:42 PMDaniel SchafferGarryalright11/18/20072:00:47 PMDaniel SchafferGarrywhat don't you get?11/18/20072:01:04 PMGarryDaniel Schafferwhat is sender? And what does getSource() do?11/18/20072:01:31 PMDaniel SchafferGarryokay when your combobox fires an event there is data that does along with the event11/18/20072:01:51 PMDaniel SchafferGarryit has a lot of generic information like what mouse buttons or keyboard keys were sent as well as information about the state of the control11/18/20072:02:17 PMDaniel SchafferGarryit also tells you which control fired the event - that's getSource() with the "source" being the source of the event itself11/18/20072:02:48 PMDaniel SchafferGarryto keep with the java naming conventions you should actually probably rename "sender" to "source" just to keep things uniform and less confusing11/18/20072:03:18 PMDaniel SchafferGarrybut what you're doing there is giving assigning the reference to the event source to a variable11/18/20072:03:35 PMDaniel SchafferGarryso you can use it later on in the method11/18/20072:04:59 PMDaniel SchafferGarrybtw putting (javax swing. JComboBox) before evt getSource() is called casting - the getSource() method returns a object of the base type Object so you have to cast the object to the JComboBox type in order to get access to the JComboBox class members11/18/20072:05:43 PMGarryDaniel Schafferalright11/18/20072:06:22 PMGarryDaniel Schafferso this will allow me to get access to a variable within private void jComboBox1ActionPerformed(java awt event. ActionEvent evt) {} ?11/18/20072:07:04 PMDaniel SchafferGarrywell its creating a variable that is a reference to the source of the event11/18/20072:07:31 PMDaniel SchafferGarryso if jComboBox1 is the control that fired the event the "source" variable will be a reference to that control.11/18/20072:08:01 PMGarryDaniel Schafferok!11/18/20072:09:39 PMGarryDaniel Schafferbut if I put the javax swing. JComboBox source = (javax swing. JComboBox)evt getSource(); in the jComboBox1ActionPerformed handler.. will that work?11/18/20072:10:06 PMDaniel SchafferGarrywork for what?11/18/20072:10:17 PMDaniel SchafferGarrywe're not done yet11/18/20072:10:18 PMGarryDaniel Schafferwill I have access to the source variable?11/18/20072:10:22 PMDaniel SchafferGarryyes11/18/20072:10:28 PMDaniel SchafferGarryjust in that method though11/18/20072:10:43 PMGarryDaniel Schafferok11/18/20072:16:58 PMDaniel SchafferGarryokay so next you'll need to get a reference to the form itself11/18/20072:17:38 PMDaniel SchafferGarrybecause once you get the value from the combobox you'll need to be able to pass it to your form11/18/20072:17:55 PMDaniel SchafferGarrysee if you can figure out how 11/18/20072:18:35 PMGarryDaniel Schafferit's funny. I like to think I'm good with google. I can usually find things on my own a lot of the time if I need to but I never can with this stuff11/18/20072:18:41 PMDaniel SchafferGarrybtw its helpful to use the java reference here's the page for the JComboBox control: 11/18/20072:23:33 PMDaniel SchafferGarryhere's a hint.. check out the methods that it inherits from the Component class11/18/20072:23:49 PMGarryDaniel SchafferI was about to say11/18/20072:23:52 PMGarryDaniel SchafferaccessibleContext11/18/20072:24:04 PMGarryDaniel Schafferam I right?11/18/20072:24:15 PMDaniel SchafferGarryi'm actually not sure what that does haha11/18/20072:24:36 PMGarryDaniel SchaffereventListener? 11/18/20072:25:21 PMDaniel SchafferGarryyou're trying to get a reference to your form11/18/20072:25:26 PMGarryDaniel Schafferok11/18/20072:25:42 PMGarryDaniel Schafferohhhh wait11/18/20072:25:43 PMDaniel SchafferGarrythe combobox is a child of the form correct?11/18/20072:25:45 PMGarryDaniel SchafferI was looking at the wrong thing11/18/20072:25:49 PMGarryDaniel Schafferyea. I think so11/18/20072:26:18 PMDaniel SchafferGarryokay so have a reference to the combobox.. how might you get from the combobox to the form?11/18/20072:26:39 PMDaniel SchafferGarryif the combobox is a *child* of the form11/18/20072:27:47 PMGarryDaniel SchafferI see a "getParent" method...11/18/20072:27:58 PMDaniel SchafferGarryok11/18/20072:28:01 PMGarryDaniel Schafferbut that seems like the opposite of what I need11/18/20072:28:05 PMDaniel SchafferGarrywhy?11/18/20072:28:19 PMGarryDaniel Schafferwell maybe not11/18/20072:29:07 PMDaniel SchafferGarryso how might you use getParent() to get a reference to your form then11/18/20072:29:31 PMDaniel SchafferGarrynote the type that getParent() returns11/18/20072:31:55 PMGarryDaniel Schafferthat's a good question11/18/20072:32:04 PMGarryDaniel SchafferBut I have no idea11/18/20072:32:20 PMGarryDaniel Schafferit says it returns what the parent is of the component11/18/20072:32:26 PMGarryDaniel SchafferI don't quite see how it helps11/18/20072:33:34 PMDaniel SchafferGarryokay do you understand what the Component class is?11/18/20072:37:52 PMGarryDaniel Schaffernot quite no11/18/20072:38:00 PMGarryDaniel SchafferI mean. I'm reading about it now11/18/20072:38:17 PMDaniel SchafferGarryokay well the Component class is a superclass of ComboBox11/18/20072:38:25 PMGarryDaniel Schafferok11/18/20072:39:26 PMDaniel SchafferGarryits also the the superclass of lots of other controls.. including JFrame11/18/20072:39:37 PMGarryDaniel Schafferright on11/18/20072:40:18 PMDaniel SchafferGarryso all of these control classes will have all of Component's members.. including the getParent() method which returns a Component object11/18/20072:41:16 PMDaniel SchafferGarryhowever just because it returns a Component object doesn't mean that the object is JUST a Component.. it could be any number of the other classes that extend Component.11/18/20072:41:48 PMDaniel SchafferGarrybut since Component is effectively the lower common denominator that's what it returns11/18/20072:42:12 PMGarryDaniel Schafferalright11/18/20072:42:37 PMDaniel SchafferGarrymake sense?11/18/20072:42:55 PMGarryDaniel Schafferas much as it is going to right now at least11/18/20072:43:21 PMDaniel SchafferGarryalright well lets see if I can make it a little clearer11/18/20072:43:47 PMDaniel SchafferGarrybecause its is a fairly big OOP principle that will help you understand a lot of other things11/18/20072:44:01 PMDaniel SchafferGarrytake a look at te hierarchy at the top of this page: 11/18/20072:44:29 PMGarryDaniel Schafferso java lang object is....11/18/20072:44:36 PMGarryDaniel Schafferthe biggest of all superclasses?11/18/20072:44:44 PMDaniel SchafferGarrywell i wouldn't say biggest11/18/20072:44:51 PMGarryDaniel Schafferoh but it is one11/18/20072:44:56 PMDaniel SchafferGarrybut EVERY class automatically inherits from Object11/18/20072:45:03 PMGarryDaniel Schafferneat11/18/20072:45:14 PMDaniel SchafferGarryeven if you have a class that doesn't inherit from anything it intrinsicly inherits from Object11/18/20072:45:32 PMDaniel SchafferGarryi should be saying "extends" not "inherits" sorry11/18/20072:45:38 PMGarryDaniel Schafferah11/18/20072:45:53 PMDaniel SchafferGarrythey mean the same thing but "extends" in the Java word for it11/18/20072:45:57 PMDaniel SchafferGarryis **11/18/20072:46:06 PMGarryDaniel Schafferok11/18/20072:46:10 PMDaniel SchafferGarryClass Object is the root of the class hierarchy. Every class has Object as a superclass. All objects including arrays implement the methods of this class.11/18/20072:46:18 PMDaniel SchafferGarry^^ from the documentation on the Object class11/18/20072:47:47 PMDaniel SchafferGarryso the hierarchy goes from less specific to more specific11/18/20072:48:41 PMGarryDaniel Schafferyea11/18/20072:58:13 PMDaniel SchafferGarryok sorry phone11/18/20072:58:19 PMGarryDaniel Schafferno problem11/18/20072:58:44 PMDaniel SchafferGarryalright so each class that extends another class gets all the members of the superclass11/18/20072:58:51 PMGarryDaniel SchafferI think I might be done with this anyways. It's a group project my group is meeting up tonight to work on it and we'll decide what we're going to do11/18/20072:59:23 PMDaniel SchafferGarryso for example the Component class has all the methods and properties of the Object class the Container class has all the methods and properties of the Component class and so on11/18/20072:59:31 PMDaniel SchafferGarryah alright11/18/20072:59:37 PMGarryDaniel SchafferThanks so much for your help11/18/20072:59:39 PMDaniel SchafferGarrynp11/18/20072:59:42 PMGarryDaniel SchafferI've definitely learned a lot these two days11/18/20072:59:49 PMGarryDaniel SchafferIt'll come eventually!11/18/20073:00:00 PMGarryDaniel SchafferI'm just very young and in-experienced11/18/20073:00:11 PMDaniel SchafferGarryit will though I'm surpised your teacher isn't giving you more theory before throwing these projects at you11/18/20073:00:27 PMGarryDaniel Schafferhe kind of is I guess but I'm not sure he's teaching it the right way11/18/20073:00:29 PMDaniel SchafferGarryit seems like there's a lot he's not teaching you11/18/20073:00:45 PMGarryDaniel Schaffervery likely11/18/20073:01:06 PMGarryDaniel Schafferand unfortunately I'm near the top of the class 11/18/20073:01:12 PMDaniel SchafferGarryalright.. well i'm glad I could help.. i'm never sure if the way I explain things helps people11/18/20073:01:32 PMGarryDaniel Schafferoh it did definitely11/18/20073:01:36 PMDaniel SchafferGarrywell awesome11/18/20073:01:49 PMGarryDaniel Schafferwell. I'm off.. busy day today. Have a good one! Talk to you again sometime11/18/20073:01:55 PMDaniel SchafferGarryk see ya

Forex Groups - Tips on Trading

Related article:
http://www.halflife2.net/forums/showthread.php?t=134672

comments | Add comment | Report as Spam


"RE: [Trinidad] Component renderer cannot be found in portal context" posted by ~Ray
Posted on 2008-03-12 23:15:20

Hi Scott. Thanks for your reply. I currently use this bridge :org apache portals bridges jsf. FacesPortlet. Do you think I should give it a try with"org apache myfaces portlet. MyFacesGenericPortlet"?I found this on the myfaces wiki. http://wiki apache org/myfaces/CreatingJSFPortlets Cheers Lorin-----Original Message-----From: Scott O'Bryan [mailto:darkarena@gmail com] Sent: Wednesday. October 31. 2007 8:36 PMTo: MyFaces DiscussionSubject: Re: [Trinidad] Component renderer cannot be found in portal contextLorin,Trinidad should be JSR-301 compliant although to be stamp the Bridge isbrand spaking new so there might come up be issues. What connect are youtrying to run Trinidad with? If it's anything OTHER then the newMyFaces portlet-bridge source. I really doubt it will work. For this project we don't even have a website up but I'm hoping to havethe code for a base website up by next Monday. ScottLorin Schoop wrote:> Hi guys>> Do you undergo any roll on this inspect? Any help / idea might be helpful! As> Trinidad claims to be JSR-168 compliant. I evaluate the damage to be in my> configuration files.. Has anyone got a working example of Trinidad running> in a portlet?>> In the meantime I tried a few more things:> - Adding a configuration parameter <output-mode>portlet</output-mode> to> trinidad-config xml; doesn't change anything.> - Removing Tomahawk; same thing.> - Specifically set the render-type of the Trinidad components: exception> saying "Render context missing".> - Change the user agent (which is unknown in both IE and Firefox) atruntime> to "Mozilla". --> User agent error disappears but the get errors> remain...>> Thanks a lot!!>> Cheers> -Lorin>>> -----Original Message-----> From: Schoop Lorin (lschoop@hsr ch) [mailto:lschoop@hsr ch]> Sent: Sunday. October 28. 2007 2:24 PM> To: users@myfaces apache org> Subject: [Trinidad] Component renderer cannot be open in portal context>> Hello>> I'd like to use Trinidad 1.0.3 in a portal application (Liferay 4.2.1 +> JBOSS 4.0.4GA). Other portlets use MyFaces 1.1.5 + Tomahawk 1.1.6. Facelet> is not being used so far.>> I've setup a simple portlet with a button which increments a counter value> using PPR.>> When I run the example. I get the following error:>>> 13:14:54,968 ERROR [STDERR] 28.10.2007 13:14:54> org apache myfaces trinidadinternal agent. AgentFactoryImpl> _populateUnknownAgentImpl>> WARNING: The User-Agent "null" is unknown; creating an agent with"unknown"> agent attributes.>> 13:14:55,281 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not sight renderer for CoreDocument[UIXFacesBeanImpl,> id=trinidadDoc] rendererType = org apache myfaces trinidad. Document>> 13:14:55,281 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not sight renderer for CoreDocument[UIXFacesBeanImpl,> id=trinidadDoc] rendererType = org apache myfaces trinidad. enter>> 13:14:55,375 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not find renderer for CoreForm[UIXFacesBeanImpl,> id=trinidadForm] rendererType = org apache myfaces trinidad. Form>> 13:14:55,375 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not find renderer for CoreForm[UIXFacesBeanImpl,> id=trinidadForm] rendererType = org apache myfaces trinidad. Form>> 13:14:55,375 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not find renderer for CoreCommandButton[UIXFacesBeanImpl,> id=counterButton] rendererType = org apache myfaces trinidad. Button>> 13:14:55,375 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not find renderer for CoreCommandButton[UIXFacesBeanImpl,> id=counterButton] rendererType = org apache myfaces trinidad. add>> 13:14:55,375 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not sight renderer for CoreOutputText[UIXFacesBeanImpl,> id=_id14d23f80] rendererType = org apache myfaces trinidad. Text>> 13:14:55,406 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not find renderer for CoreOutputText[UIXFacesBeanImpl,> id=_id14d23f80] rendererType = org apache myfaces trinidad. Text>>>>>> I think PPR is not the problem. I tried a different example without> partialSubmit / partialTriggers attributes: same errors.>> Extracts of the related files are attached below.>>>> I appreciate your help very much!! Thanks in advance!>>>> Regards,>> -Lorin>>>>>>****************************************************************************> *>> TrinidadTest jsp >>>>>> <%@ summon session="false" contentType="text/html; charset=ISO-8859-1"%>>> <%@ taglib uri="http://java sun com/jsf/core" affix="f"%>>> <%@ taglib uri="http://java sun com/portlet" prefix="portlet"%>>> <%@ taglib uri="http://myfaces apache org/trinidad" prefix="tr"%>>> <portlet:defineObjects />>> <cerebrate rel="stylesheet" type="text/css">> href="<%= renderResponse encodeURL(renderRequest getContextPath() +> "/css/basic css") %>" />>> <f:view>>> <tr:document id="trinidadDoc">>> <TITLE>Order Entry</TITLE>>> <tr:form id="trinidadForm">>> <tr:commandButton text="Increment answer" id="counterButton">> partialSubmit="adjust" actionListener="#{trinidadTestBean increment}" />>> <tr:outputText value="#{trinidadTestBean counter}"> partialTriggers="counterButton" />>> </tr:form>>> </tr:enter>>> </f:believe>>>>>****************************************************************************> *>> TrinidadTestBean java >>>>>> package test;>> import javax faces event. ActionEvent;>> public class TrinidadTestBean {>> private int counter = 0;>> public cancel increment(ActionEvent event)>> {>> // Change the text value>> counter++;>> }>> public int getCounter() {>> go answer;>> }>> public void setCounter(int counter) {>> this answer = answer;>> }>> }>>>>****************************************************************************> *>> web xml >>>>>> <?xml version="1.0" encoding="UTF-8"?>>> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems. Inc.//DTD Web Application> 2.3//EN" "http://java sun com/dtd/web-app_2_3 dtd">>> <web-app id="WebApp_ID">>> <display-name>testPortalApp</display-name>>> <context-param>>> <param-name>company_id</param-name>>> <param-value>liferay com</param-value>>> </context-param>>> <context-param>>> <param-name>javax faces. CONFIG_FILES</param-name>>> <param-value>/WEB-INF/faces-config xml</param-value>>> </context-param>>> <context-param>>> <param-name>com sun faces validateXml</param-name>>> <param-value>true</param-value>>> </context-param>>> <context-param>>> <param-name>javax faces. STATE_SAVING_METHOD</param-name>>> <param-value>server</param-value>>> </context-param>>> <context-param>>> <param-name>org apache myfaces. accept_JAVASCRIPT</param-name>>> <param-value>adjust</param-value>>> </context-param>>> <context-param>>> <param-name>org apache myfaces. PRETTY_HTML</param-name>>> <param-value>true</param-value>>> </context-param>>> <context-param>>> <param-name>org apache myfaces. DETECT_JAVASCRIPT</param-name>>> <param-value>false</param-value>>> </context-param>>> <context-param>>> <param-name>org apache myfaces. AUTO_SCROLL</param-name>>> <param-value>true</param-value>>> </context-param>>> <filter>>> <filter-name>trinidad</filter-name>>> <filter-class>>> org apache myfaces trinidad webapp. TrinidadFilter>> </filter-class>>> </filter>>> <filter-mapping>>> <filter-name>trinidad</filter-name>>> <servlet-name>TrinidadTestPortlet</servlet-name>>> </filter-mapping>>> <listener>>> <listener-class>>> com liferay portal kernel servlet. PortletContextListener>> </listener-class>>> </listener>>> <listener>>> <listener-class>>> org apache myfaces webapp. StartupServletContextListener>> </listener-class>>> </listener>>> <!-- resource loader servlet -->>> <servlet>>> <servlet-name>resources</servlet-name>>> <servlet-class>>> org apache myfaces trinidad webapp. ResourceServlet>> </servlet-class>>> </servlet>>> <servlet>>> <servlet-name>TrinidadTestPortlet</servlet-name>>> <servlet-class>>> com liferay portal kernel servlet. PortletServlet>> </servlet-class>>> <init-param>>> <param-name>portlet-class</param-name>>> <param-value>>> org apache portals bridges jsf. FacesPortlet>> </param-value>>> </init-param>>> <load-on-startup>1</load-on-startup>>> </servlet>>> <servlet-mapping>>> <servlet-name>resources</servlet-name>>> <url-pattern>/adf/*</url-pattern>>> </servlet-mapping>>> <servlet-mapping>>> <servlet-name>TrinidadTestPortlet</servlet-name>>> <url-pattern>/TrinidadTestPortlet/*</url-pattern>>> </servlet-mapping>>>>> <taglib id="LiferayTLD">>> <taglib-uri>http://java sun com/portlet</taglib-uri>>> <taglib-location>>> /WEB-INF/tld/liferay-portlet tld>> </taglib-location>>> </taglib>>> </web-app>>>>>****************************************************************************> *>> trinidad-config xml >>>>>>> <?xml version="1.0"?>>> <trinidad-config xmlns="http://myfaces apache org/trinidad/config">>> <!-- Enable debug create -->>> <debug-output>adjust</debug-output>>> <!-- Pick accessibility options based on a per-user managed bean -->>> <accessibility-mode>fail</accessibility-mode>>> <client-validation>INLINE</client-validation>>> <skin-family>minimal</skin-family>>> </trinidad-config>>>>>>>****************************************************************************> *>> faces-config xml >>>>>> <?xml version="1.0"?>>> <!DOCTYPE faces-config PUBLIC>> "-//Sun Microsystems. Inc.//DTD JavaServer Faces Config 1.0//EN">> "http://java sun com/dtd/web-facesconfig_1_0 dtd">>> <!-->> Copyright 2003 Sun Microsystems. Inc. All rights reserved.>> SUN PROPRIETARY/CONFIDENTIAL. Use is subject to authorise terms.>> -->>> <!-- =========== beat CONFIGURATION register==================================> -->>> <faces-config>>> <component>>><component-type>org apache myfaces. HtmlPanelNavigationMenu</component-type>>><component-class>org apache myfaces custom navmenu htmlnavmenu. HtmlPanelNavi> gationMenu</component-class>>> </component>>> <component>>> <component-type>org apache myfaces. HtmlCommandSortHeader</component-type>>><component-class>org apache myfaces custom sortheader. HtmlCommandSortHeader<> /component-class>>> </component>>> <application>>> <default-render-kit-id>>> org apache myfaces trinidad core>> </default-render-kit-id>>> </application>>> <render-kit>>> <render-kit-id>HTML_BASIC</render-kit-id>>> <renderer>>> <component-family>javax faces. adorn</component-family>>> <renderer-type>org apache myfaces. NavigationMenu</renderer-type>>><renderer-class>org apache myfaces custom navmenu htmlnavmenu. HtmlNavigation> MenuRenderer</renderer-class>>> </renderer>>> <renderer>>> <component-family>javax faces. Command</component-family>>> <renderer-type>org apache myfaces. SortHeader</renderer-type>>><renderer-class>org apache myfaces custom sortheader. HtmlSortHeaderRenderer<> /renderer-class>>> </renderer>>> </render-kit>>> <managed-bean>>> <managed-bean-name>trinidadTestBean</managed-bean-name>>> <managed-bean-class>test. TrinidadTestBean</managed-bean-class>>> <managed-bean-scope>session</managed-bean-scope>>> </managed-bean>>> </faces-config>>>>>>>>

Forex Groups - Tips on Trading

Related article:
http://mail-archives.apache.org/mod_mbox/myfaces-users/200710.mbox/%3C004501c81bf7$c729da20$557d8e60$@ch%3E

comments | Add comment | Report as Spam


"RE: [Trinidad] Component renderer cannot be found in portal context" posted by ~Ray
Posted on 2008-03-12 23:15:20

Hi Scott. Thanks for your reply. I currently use this connect :org apache portals bridges jsf. FacesPortlet. Do you evaluate I should give it a try with"org apache myfaces portlet. MyFacesGenericPortlet"?I found this on the myfaces wiki. http://wiki apache org/myfaces/CreatingJSFPortlets Cheers Lorin-----Original Message-----From: Scott O'Bryan [mailto:darkarena@gmail com] Sent: Wednesday. October 31. 2007 8:36 PMTo: MyFaces DiscussionSubject: Re: [Trinidad] Component renderer cannot be found in portal contextLorin,Trinidad should be JSR-301 compliant although to be stamp the Bridge isbrand spaking new so there might well be issues. What connect are youtrying to run Trinidad with? If it's anything OTHER then the newMyFaces portlet-bridge source. I really doubt it will work. For this project we don't even have a website up but I'm hoping to havethe code for a locate website up by next Monday. ScottLorin Schoop wrote:> Hi guys>> Do you have any clue on this inspect? Any help / idea might be helpful! As> Trinidad claims to be JSR-168 compliant. I expect the damage to be in my> configuration files.. Has anyone got a working example of Trinidad running> in a portlet?>> In the meantime I tried a few more things:> - Adding a configuration parameter <output-mode>portlet</output-mode> to> trinidad-config xml; doesn't dress anything.> - Removing Tomahawk; same thing.> - Specifically set the render-type of the Trinidad components: exception> saying "Render context missing".> - Change the user agent (which is unknown in both IE and Firefox) atruntime> to "Mozilla". --> User agent error disappears but the render errors> remain...>> Thanks a lot!!>> Cheers> -Lorin>>> -----Original Message-----> From: Schoop Lorin (lschoop@hsr ch) [mailto:lschoop@hsr ch]> Sent: Sunday. October 28. 2007 2:24 PM> To: users@myfaces apache org> Subject: [Trinidad] Component renderer cannot be found in portal context>> Hello>> I'd like to use Trinidad 1.0.3 in a portal application (Liferay 4.2.1 +> JBOSS 4.0.4GA). Other portlets use MyFaces 1.1.5 + Tomahawk 1.1.6. Facelet> is not being used so far.>> I've setup a simple portlet with a button which increments a counter determine> using PPR.>> When I run the example. I get the following error:>>> 13:14:54,968 ERROR [STDERR] 28.10.2007 13:14:54> org apache myfaces trinidadinternal agent. AgentFactoryImpl> _populateUnknownAgentImpl>> WARNING: The User-Agent "null" is unknown; creating an agent with"unknown"> agent attributes.>> 13:14:55,281 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not find renderer for CoreDocument[UIXFacesBeanImpl,> id=trinidadDoc] rendererType = org apache myfaces trinidad. Document>> 13:14:55,281 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not find renderer for CoreDocument[UIXFacesBeanImpl,> id=trinidadDoc] rendererType = org apache myfaces trinidad. enter>> 13:14:55,375 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not find renderer for CoreForm[UIXFacesBeanImpl,> id=trinidadForm] rendererType = org apache myfaces trinidad. Form>> 13:14:55,375 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not sight renderer for CoreForm[UIXFacesBeanImpl,> id=trinidadForm] rendererType = org apache myfaces trinidad. create>> 13:14:55,375 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not find renderer for CoreCommandButton[UIXFacesBeanImpl,> id=counterButton] rendererType = org apache myfaces trinidad. add>> 13:14:55,375 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not sight renderer for CoreCommandButton[UIXFacesBeanImpl,> id=counterButton] rendererType = org apache myfaces trinidad. add>> 13:14:55,375 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not find renderer for CoreOutputText[UIXFacesBeanImpl,> id=_id14d23f80] rendererType = org apache myfaces trinidad. Text>> 13:14:55,406 ERROR [STDERR] 28.10.2007 13:14:55> org apache myfaces trinidad component. UIXComponentBase _getRendererImpl>> WARNING: Could not find renderer for CoreOutputText[UIXFacesBeanImpl,> id=_id14d23f80] rendererType = org apache myfaces trinidad. Text>>>>>> I think PPR is not the problem. I tried a different example without> partialSubmit / partialTriggers attributes: same errors.>> Extracts of the related files are attached below.>>>> I acknowledge your back up very much!! Thanks in advance!>>>> Regards,>> -Lorin>>>>>>****************************************************************************> *>> TrinidadTest jsp >>>>>> <%@ page session="false" contentType="text/html; charset=ISO-8859-1"%>>> <%@ taglib uri="http://java sun com/jsf/core" prefix="f"%>>> <%@ taglib uri="http://java sun com/portlet" affix="portlet"%>>> <%@ taglib uri="http://myfaces apache org/trinidad" prefix="tr"%>>> <portlet:defineObjects />>> <link rel="stylesheet" type="text/css">> href="<%= renderResponse encodeURL(renderRequest getContextPath() +> "/css/basic css") %>" />>> <f:view>>> <tr:document id="trinidadDoc">>> <TITLE>Order Entry</call>>> <tr:form id="trinidadForm">>> <tr:commandButton text="Increment Counter" id="counterButton">> partialSubmit="true" actionListener="#{trinidadTestBean increment}" />>> <tr:outputText value="#{trinidadTestBean counter}"> partialTriggers="counterButton" />>> </tr:form>>> </tr:document>>> </f:believe>>>>>****************************************************************************> *>> TrinidadTestBean java >>>>>> package evaluate;>> import javax faces event. ActionEvent;>> public class TrinidadTestBean {>> private int counter = 0;>> public void increment(ActionEvent event)>> {>> // Change the text value>> answer++;>> }>> public int getCounter() {>> return counter;>> }>> public void setCounter(int counter) {>> this answer = counter;>> }>> }>>>>****************************************************************************> *>> web xml >>>>>> <?xml version="1.0" encoding="UTF-8"?>>> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems. Inc.//DTD Web Application> 2.3//EN" "http://java sun com/dtd/web-app_2_3 dtd">>> <web-app id="WebApp_ID">>> <display-name>testPortalApp</display-name>>> <context-param>>> <param-name>company_id</param-name>>> <param-value>liferay com</param-value>>> </context-param>>> <context-param>>> <param-name>javax faces. CONFIG_FILES</param-name>>> <param-value>/WEB-INF/faces-config xml</param-value>>> </context-param>>> <context-param>>> <param-name>com sun faces validateXml</param-name>>> <param-value>true</param-value>>> </context-param>>> <context-param>>> <param-name>javax faces. STATE_SAVING_METHOD</param-name>>> <param-value>server</param-value>>> </context-param>>> <context-param>>> <param-name>org apache myfaces. ALLOW_JAVASCRIPT</param-name>>> <param-value>true</param-value>>> </context-param>>> <context-param>>> <param-name>org apache myfaces. PRETTY_HTML</param-name>>> <param-value>adjust</param-value>>> </context-param>>> <context-param>>> <param-name>org apache myfaces. sight_JAVASCRIPT</param-name>>> <param-value>false</param-value>>> </context-param>>> <context-param>>> <param-name>org apache myfaces. AUTO_move</param-name>>> <param-value>adjust</param-value>>> </context-param>>> <separate>>> <filter-name>trinidad</filter-name>>> <filter-class>>> org apache myfaces trinidad webapp. TrinidadFilter>> </filter-class>>> </separate>>> <filter-mapping>>> <filter-name>trinidad</filter-name>>> <servlet-name>TrinidadTestPortlet</servlet-name>>> </filter-mapping>>> <listener>>> <listener-class>>> com liferay portal kernel servlet. PortletContextListener>> </listener-class>>> </listener>>> <listener>>> <listener-class>>> org apache myfaces webapp. StartupServletContextListener>> </listener-class>>> </listener>>> <!-- resource loader servlet -->>> <servlet>>> <servlet-name>resources</servlet-name>>> <servlet-class>>> org apache myfaces trinidad webapp. ResourceServlet>> </servlet-class>>> </servlet>>> <servlet>>> <servlet-name>TrinidadTestPortlet</servlet-name>>> <servlet-class>>> com liferay portal kernel servlet. PortletServlet>> </servlet-class>>> <init-param>>> <param-name>portlet-class</param-name>>> <param-value>>> org apache portals bridges jsf. FacesPortlet>> </param-value>>> </init-param>>> <load-on-startup>1</load-on-startup>>> </servlet>>> <servlet-mapping>>> <servlet-name>resources</servlet-name>>> <url-pattern>/adf/*</url-pattern>>> </servlet-mapping>>> <servlet-mapping>>> <servlet-name>TrinidadTestPortlet</servlet-name>>> <url-pattern>/TrinidadTestPortlet/*</url-pattern>>> </servlet-mapping>>>>> <taglib id="LiferayTLD">>> <taglib-uri>http://java sun com/portlet</taglib-uri>>> <taglib-location>>> /WEB-INF/tld/liferay-portlet tld>> </taglib-location>>> </taglib>>> </web-app>>>>>****************************************************************************> *>> trinidad-config xml >>>>>>> <?xml version="1.0"?>>> <trinidad-config xmlns="http://myfaces apache org/trinidad/config">>> <!-- alter correct output -->>> <debug-output>true</debug-output>>> <!-- Pick accessibility options based on a per-user managed hit -->>> <accessibility-mode>default</accessibility-mode>>> <client-validation>INLINE</client-validation>>> <skin-family>minimal</skin-family>>> </trinidad-config>>>>>>>****************************************************************************> *>> faces-config xml >>>>>> <?xml version="1.0"?>>> <!DOCTYPE faces-config PUBLIC>> "-//Sun Microsystems. Inc.//DTD JavaServer Faces Config 1.0//EN">> "http://java sun com/dtd/web-facesconfig_1_0 dtd">>> <!-->> procure 2003 Sun Microsystems. Inc. All rights reserved.>> SUN PROPRIETARY/CONFIDENTIAL. Use is subject to authorise terms.>> -->>> <!-- =========== beat CONFIGURATION FILE==================================> -->>> <faces-config>>> <component>>><component-type>org apache myfaces. HtmlPanelNavigationMenu</component-type>>><component-class>org apache myfaces custom navmenu htmlnavmenu. HtmlPanelNavi> gationMenu</component-class>>> </component>>> <component>>> <component-type>org apache myfaces. HtmlCommandSortHeader</component-type>>><component-class>org apache myfaces custom sortheader. HtmlCommandSortHeader<> /component-class>>> </component>>> <application>>> <default-render-kit-id>>> org apache myfaces trinidad core>> </default-render-kit-id>>> </application>>> <render-kit>>> <render-kit-id>HTML_BASIC</render-kit-id>>> <renderer>>> <component-family>javax faces. Panel</component-family>>> <renderer-type>org apache myfaces. NavigationMenu</renderer-type>>><renderer-class>org apache myfaces custom navmenu htmlnavmenu. HtmlNavigation> MenuRenderer</renderer-class>>> </renderer>>> <renderer>>> <component-family>javax faces. Command</component-family>>> <renderer-type>org apache myfaces. SortHeader</renderer-type>>><renderer-class>org apache myfaces custom sortheader. HtmlSortHeaderRenderer<> /renderer-class>>> </renderer>>> </render-kit>>> <managed-bean>>> <managed-bean-name>trinidadTestBean</managed-bean-name>>> <managed-bean-class>test. TrinidadTestBean</managed-bean-class>>> <managed-bean-scope>session</managed-bean-scope>>> </managed-bean>>> </faces-config>>>>>>>>

Forex Groups - Tips on Trading

Related article:
http://mail-archives.apache.org/mod_mbox/myfaces-users/200710.mbox/%3C004501c81bf7$c729da20$557d8e60$@ch%3E

comments | Add comment | Report as Spam


"RE: [Trinidad] Component renderer cannot be found in portal context" posted by ~Ray
Posted on 2008-01-01 21:19:17

Hi guysDo you have any clue on this case? Any help / idea might be helpful! AsTrinidad claims to be JSR-168 compliant. I expect the flaw to be in myconfiguration files.. Has anyone got a working example of Trinidad runningin a portlet?In the meantime I tried a few more things:- Adding a configuration parameter <output-mode>portlet</output-mode> totrinidad-config xml; doesn't change anything.- Removing Tomahawk; same thing.- Specifically set the render-type of the Trinidad components: exceptionsaying "Render context missing". - Change the user agent (which is unknown in both IE and Firefox) at runtimeto "Mozilla". --> User agent error disappears but the render errorsremain... Thanks a lot!!Cheers-Lorin-----Original Message-----From: Schoop Lorin (lschoop@hsr ch) [mailto:lschoop@hsr ch] Sent: Sunday. October 28. 2007 2:24 PMTo: users@myfaces apache orgSubject: [Trinidad] Component renderer cannot be open in portal contextHelloI'd desire to use Trinidad 1.0.3 in a portal application (Liferay 4.2.1 +JBOSS 4.0.4GA). Other portlets use MyFaces 1.1.5 + cut 1.1.6. Faceletis not being used so far. I've setup a simple portlet with a button which increments a counter valueusing PPR. When I run the example. I get the following error:13:14:54,968 ERROR [STDERR] 28.10.2007 13:14:54org apache myfaces trinidadinternal agent. AgentFactoryImpl_populateUnknownAgentImplWARNING: The User-Agent "null" is unknown; creating an agent with "unknown"agent attributes.13:14:55,281 ERROR [STDERR] 28.10.2007 13:14:55org apache myfaces trinidad component. UIXComponentBase _getRendererImplWARNING: Could not find renderer for CoreDocument[UIXFacesBeanImpl,id=trinidadDoc] rendererType = org apache myfaces trinidad. enter13:14:55,281 ERROR [STDERR] 28.10.2007 13:14:55org apache myfaces trinidad component. UIXComponentBase _getRendererImplWARNING: Could not find renderer for CoreDocument[UIXFacesBeanImpl,id=trinidadDoc] rendererType = org apache myfaces trinidad. Document13:14:55,375 ERROR [STDERR] 28.10.2007 13:14:55org apache myfaces trinidad component. UIXComponentBase _getRendererImplWARNING: Could not sight renderer for CoreForm[UIXFacesBeanImpl,id=trinidadForm] rendererType = org apache myfaces trinidad. Form13:14:55,375 ERROR [STDERR] 28.10.2007 13:14:55org apache myfaces trinidad component. UIXComponentBase _getRendererImplWARNING: Could not find renderer for CoreForm[UIXFacesBeanImpl,id=trinidadForm] rendererType = org apache myfaces trinidad. Form13:14:55,375 ERROR.

Forex Groups - Tips on Trading

Related article:
http://mail-archives.apache.org/mod_mbox/myfaces-users/200710.mbox/%3C001a01c81bc1$88151420$983f3c60$@ch%3E

comments | Add comment | Report as Spam


"???????20040603918" posted by ~Ray
Posted on 2007-12-15 15:08:33

public categorise NewFile extends javax swing. JFrame { publicNewFile() { initComponents(); } private voidinitComponents() { jScrollPane1 = new javax swing. JScrollPane(); circumscribe = new javax swing. JTextPane(); jPanel1 = new javax swing. JPanel(); ok = new javax displace. JButton(); exit = new javax swing. JButton(); setDefaultCloseOperation(javax swing. WindowConstants. EXIT_ON_change state); setTitle("帮助主题"); setBackground(new java awt. Color(204. 204. 255)); setMinimumSize(new java awt. Dimension(100. 100)); jScrollPane1 setMaximumSize(new java awt. Dimension(400,500)); jScrollPane1 setPreferredSize(new java awt. Dimension(400,550)); content setText("没有内容"); content setMaximumSize(new java awt. mark(400. 500)); content setPreferredSize(new java awt. mark(400. 500)); jScrollPane1 setViewportView(content); ok setText("确定"); ok addActionListener(new java awt event. ActionListener() { public void actionPerformed(java awt event. ActionEvent evt) { okActionPerformed(evt); } }); move setText("退出"); exit addActionListener(new java awt event. ActionListener() { public cancel actionPerformed(java awt event. ActionEvent evt) { exitActionPerformed(evt); } }); privatevoid okActionPerformed(java awt event. ActionEvent evt) { JOptionPane showMessageDialog(this,"没什么可以确定的"); } privatejavax displace. JTextPane content; privatejavax swing. JButton move; privatejavax displace. JPanel jPanel1; privatejavax swing. JScrollPane jScrollPane1; privatejavax displace. JButton ok; } public categorise NewJFrame extendsjavax swing. JFrame { publicNewJFrame() { initComponents(); } private voidinitComponents() { menuBar = new javax displace. JMenuBar(); file = new javax displace. JMenu(); newFile = new javax swing. JMenuItem(); openFile = new javax swing. JMenu(); openTxt = new javax swing. JMenuItem(); openDoc = new javax swing. JMenuItem(); save = new javax swing. JMenu(); saveTxt = new javax swing. JMenuItem(); saveDoc = new javax displace. JMenuItem(); exit = new javax swing. JMenuItem(); back up = new javax displace. JMenu(); helpSubject = new javax displace. JMenuItem(); about = new javax swing. JMenuItem(); pack(); } private voidhelpSubjectActionPerformed(java awt event. ActionEvent evt){ NewFile jf=new NewFile(); jf setSize(500,500); jf setLocation((1024-400)/2,(768-500)/2); jf setVisible(adjust); } private voidexitActionPerformed(java awt event. ActionEvent evt){ System exit(1); } publicstatic void main(String args[]) { NewJFrame nf=new NewJFrame(); nf setSize(400,400); nf setLocation((1024-400)/2,(768-400)/2); nf setVisible(true); } privatejavax displace. JMenuItem about; privatejavax displace. JMenuItem exit; privatejavax displace. JMenu file; privatejavax swing. JMenu help; privatejavax displace. JMenuItem helpSubject; privatejavax swing. JMenuBar menuBar; privatejavax displace. JMenuItem newFile; privatejavax swing. JMenuItem openDoc; privatejavax displace. JMenu openFile; privatejavax displace. JMenuItem openTxt; privatejavax swing. JMenu save; privatejavax displace. JMenuItem saveDoc; privatejavax swing. JMenuItem saveTxt; }

Forex Groups - Tips on Trading

Related article:
http://blog.sina.com.cn/s/blog_4e9e375101000bdb.html

comments | Add comment | Report as Spam


"GUI Building with Scala" posted by ~Ray
Posted on 2007-12-09 13:41:26

One the strengths of Scala is a flexible syntax that allows for Scala label be more desire a Domain Specific Language. A while approve. I started to put such a Scala "DSL" together inspired in part by what was then known as F3 but has since been re-branded. JavaFX. This idea languished for few months while I got distracted by other pursuits. I've decided to publish what I undergo produced so far to get feedback about it and determine if such a thing is a worth continuing. I've published the supporting classes in a jar file available along with a simple example. verify the jar above is on the CLASSPATH hive away and run the example program: package tfd scala guibuilder demoobject GuiBuilderSimple extends Application { import java awt.{Color. FlowLayout} import java awt event. ActionEvent import javax swing. JFrame import tfd scala guibuilder._ var frm = frame( attributes( 'title->"GUIBuilder Simple Demo". 'defaultCloseOperation->JFrame. move_ON_change state ) flowlayout(attributes('alignment -> FlowLayout. LEFT)) contents( button("PressButton" attributes('text->"touch" ,'foreground->alter blue)) label("PressLabel" attributes('text->"Not Pressed",'foreground->alter red)) ) ) button onAction("PressButton",(ae: ActionEvent) => { label applyAttributes("PressLabel" attributes('text -> "Pressed". 'bring out -> alter color)) }) frm pack frm setVisible(adjust)} So what's going on here ? Each component is represented by a Scala object with overloaded "apply" methods that be various options of constructing the component. In other words they are factories. To prevent confusion or collisions with existing class names the component objects names are all lowercase. If "close in" was used instead of "close in" then it becomes unwieldy if the schedule wants to "merchandise java awt. Frame". The "attributes" are also processed by a factory disapprove via its "apply" method. I could have used "List(<attribute1>,<attribute2>...)" or "<evaluate1> :: <attribute2> ... :: Nil" for listing the attributes but I conclude it's more concise to use "attributes". It would be nice if Scala supported lists in more shorthanded way like Erlang or Ocaml then I could have done something desire "[<attribute1>,<attribute2>...]". I opted to use Scala symbols for the attribute names to save a keystroke and decrease problems from trailing quotes being omitted. Using strings would have required label like: The "frame" factory disapprove returns the JFrame it constructed and takes the following parameters:- The "attributes" represent mappings of bean properties to values. The library ordain use introspection to look for get methods to create in request to set the attribute.- A layout manager specification. Here the "flowlayout" object ordain return a java awt. Flowlayout to be used for the content pane of the frame.- The "contents" object specifies the components to be added to the close in's content pane using the specified layout manager. Here since we are using a FlowLayout we don't need to provide constraints for the layout manager in the contents. Using more complicated layout managers will require such constraints in the contents.- The components added here are simply a button and denominate which map to Swing JButton and JLabel components respectively. The first parameter passed to their "constructor" object is an optional arrange identifier that allows the component to be looked up later using an "id" method on the factory object. Example 'var btn = add id("PressButton")' will assign the JButton with id of "PressButton" to variable "btn". The add onAction method takes the string id for the button and function object with an ActionEvent parameter and adds an ActionListener to the button that delegates it's actionPerformed label to the passed answer disapprove. The body of the answer object invokes an applyAttributes method on the denominate applies evaluate to a label specifies by the string id. The same can can accomplished in a more Java desire style with the code below: Cool. I didn't experience that Scala had symbols. Since you're using them why not use them for IDs too? Is it a matter of compatibility with displace?Two other things:[1] If there is a small set of common properties for all displace components inspect classes would be nicer than symbols since they could be checked at hive away measure. But I don't evaluate there is enough homogeneity to displace properties to make it worthwhile.[2] Is it possible to use variable-arity arguments to get rid of "attributes"? I would think the type of add for example could dress fromdef apply(id : String attrs : attributes)todef apply(id : arrange attrs : (Symbol attribute)*)and used thusbutton("id". 'text -> "touch". 'foreground -> alter color)I'm not certain this will work though. Actually what type is attributes apply? It looks like you're already doing variable arity there. Disclaimer: I know very little about displace. I am a Software Engineer at Object Computing Inc. Previously at A. G. Edwards (which is soon to be Wachovia Securities). I am mostly a Java developer that is always interested in trends in software development. I've been recently learning about Functional languages like Erlang. Haskell and F# along with the Functional/OO hybrid language for the Java Virtual Machine. Scala. On the personal front. I am happily married to Karla since 1999 with two children. John and Elizabeth who were born in 2001 and 2005 respectively.

Forex Groups - Tips on Trading

Related article:
http://compulsiontocode.blogspot.com/2007/10/gui-building-with-scala.html

comments | Add comment | Report as Spam


"GUI Building with Scala" posted by ~Ray
Posted on 2007-12-09 13:41:25

One the strengths of Scala is a flexible syntax that allows for Scala code be more like a Domain Specific Language. A while back. I started to put such a Scala "DSL" together inspired in part by what was then known as F3 but has since been re-branded. JavaFX. This idea languished for few months while I got distracted by other pursuits. I've decided to create what I have produced so far to get feedback about it and determine if such a thing is a worth continuing. I've published the supporting classes in a jar register available along with a simple example. Ensure the jar above is on the CLASSPATH hive away and run the example program: package tfd scala guibuilder demoobject GuiBuilderSimple extends Application { import java awt.{alter. FlowLayout} import java awt event. ActionEvent import javax displace. JFrame merchandise tfd scala guibuilder._ var frm = frame( attributes( 'title->"GUIBuilder Simple Demo". 'defaultCloseOperation->JFrame. move_ON_change state ) flowlayout(attributes('alignment -> FlowLayout. LEFT)) contents( add("PressButton" attributes('text->"Press" ,'foreground->Color blue)) label("PressLabel" attributes('text->"Not Pressed",'foreground->alter red)) ) ) button onAction("PressButton",(ae: ActionEvent) => { denominate applyAttributes("PressLabel" attributes('text -> "Pressed". 'bring out -> Color color)) }) frm pack frm setVisible(adjust)} So what's going on here ? Each component is represented by a Scala disapprove with overloaded "bear on" methods that be various options of constructing the component. In other words they are factories. To prevent confusion or collisions with existing class names the component objects names are all lowercase. If "close in" was used instead of "close in" then it becomes unwieldy if the program wants to "import java awt. Frame". The "attributes" are also processed by a factory object via its "apply" method. I could have used "List(<attribute1>,<evaluate2>...)" or "<attribute1> :: <attribute2> ... :: Nil" for listing the attributes but I feel it's more concise to use "attributes". It would be nice if Scala supported lists in more shorthanded way like Erlang or Ocaml then I could have done something like "[<attribute1>,<attribute2>...]". I opted to use Scala symbols for the attribute names to deliver a keystroke and reduce problems from trailing quotes being omitted. Using strings would have required label desire: The "close in" factory disapprove returns the JFrame it constructed and takes the following parameters:- The "attributes" be mappings of bean properties to values. The library ordain use introspection to be for get methods to create in request to set the evaluate.- A layout manager specification. Here the "flowlayout" object ordain go a java awt. Flowlayout to be used for the circumscribe pane of the close in.- The "contents" object specifies the components to be added to the close in's circumscribe pane using the specified layout manager. Here since we are using a FlowLayout we don't be to provide constraints for the layout manager in the contents. Using more complicated layout managers will demand such constraints in the contents.- The components added here are simply a add and label which map to displace JButton and JLabel components respectively. The first parameter passed to their "constructor" object is an optional string identifier that allows the component to be looked up later using an "id" method on the factory disapprove. Example 'var btn = add id("PressButton")' ordain assign the JButton with id of "PressButton" to variable "btn". The button onAction method takes the arrange id for the add and answer object with an ActionEvent parameter and adds an ActionListener to the add that delegates it's actionPerformed call to the passed function disapprove. The be of the answer disapprove invokes an applyAttributes method on the label applies evaluate to a label specifies by the string id. The same can can accomplished in a more Java desire call with the code below: Cool. I didn't experience that Scala had symbols. Since you're using them why not use them for IDs too? Is it a be of compatibility with Swing?Two other things:[1] If there is a small set of common properties for all Swing components case classes would be nicer than symbols since they could be checked at compile measure. But I don't evaluate there is enough homogeneity to Swing properties to alter it worthwhile.[2] Is it possible to use variable-arity arguments to get rid of "attributes"? I would think the type of button for example could dress fromdef bear on(id : String attrs : attributes)todef apply(id : arrange attrs : (Symbol attribute)*)and used thusbutton("id". 'text -> "touch". 'foreground -> Color blue)I'm not certain this ordain work though. Actually what type is attributes bear on? It looks desire you're already doing variable arity there. Disclaimer: I experience very little about Swing. I am a Software design at disapprove Computing Inc. Previously at A. G. Edwards (which is soon to be Wachovia Securities). I am mostly a Java developer that is always interested in trends in software development. I've been recently learning about Functional languages like Erlang. Haskell and F# along with the Functional/OO hybrid language for the Java Virtual Machine. Scala. On the personal front. I am happily married to Karla since 1999 with two children. John and Elizabeth who were born in 2001 and 2005 respectively.

Forex Groups - Tips on Trading

Related article:
http://compulsiontocode.blogspot.com/2007/10/gui-building-with-scala.html

comments | Add comment | Report as Spam


"GUI Building with Scala" posted by ~Ray
Posted on 2007-12-09 13:41:25

One the strengths of Scala is a flexible syntax that allows for Scala label be more like a Domain Specific Language. A while back. I started to put such a Scala "DSL" together inspired in part by what was then known as F3 but has since been re-branded. JavaFX. This idea languished for few months while I got distracted by other pursuits. I've decided to create what I have produced so far to get feedback about it and cause if such a thing is a worth continuing. I've published the supporting classes in a jar file available along with a simple example. Ensure the jar above is on the CLASSPATH compile and run the example program: case tfd scala guibuilder demoobject GuiBuilderSimple extends Application { import java awt.{Color. FlowLayout} merchandise java awt event. ActionEvent merchandise javax displace. JFrame import tfd scala guibuilder._ var frm = frame( attributes( 'title->"GUIBuilder Simple Demo". 'defaultCloseOperation->JFrame. EXIT_ON_CLOSE ) flowlayout(attributes('alignment -> FlowLayout. LEFT)) contents( button("PressButton" attributes('text->"Press" ,'foreground->Color color)) denominate("PressLabel" attributes('text->"Not Pressed",'foreground->alter red)) ) ) add onAction("PressButton",(ae: ActionEvent) => { label applyAttributes("PressLabel" attributes('text -> "Pressed". 'foreground -> alter black)) }) frm pack frm setVisible(adjust)} So what's going on here ? Each component is represented by a Scala disapprove with overloaded "bear on" methods that be various options of constructing the component. In other words they are factories. To prevent confusion or collisions with existing categorise names the component objects names are all lowercase. If "close in" was used instead of "frame" then it becomes unwieldy if the schedule wants to "import java awt. Frame". The "attributes" are also processed by a factory object via its "bear on" method. I could undergo used "List(<attribute1>,<attribute2>...)" or "<evaluate1> :: <attribute2> ... :: Nil" for listing the attributes but I conclude it's more concise to use "attributes". It would be nice if Scala supported lists in more shorthanded way like Erlang or Ocaml then I could undergo done something desire "[<attribute1>,<evaluate2>...]". I opted to use Scala symbols for the attribute names to save a keystroke and reduce problems from trailing quotes being omitted. Using strings would have required label like: The "frame" factory object returns the JFrame it constructed and takes the following parameters:- The "attributes" represent mappings of hit properties to values. The library will use introspection to look for get methods to create in order to set the evaluate.- A layout manager specification. Here the "flowlayout" object will return a java awt. Flowlayout to be used for the content pane of the close in.- The "contents" object specifies the components to be added to the frame's content pane using the specified layout manager. Here since we are using a FlowLayout we don't be to provide constraints for the layout manager in the contents. Using more complicated layout managers will demand such constraints in the contents.- The components added here are simply a button and label which map to displace JButton and JLabel components respectively. The first parameter passed to their "constructor" disapprove is an optional string identifier that allows the component to be looked up later using an "id" method on the factory disapprove. Example 'var btn = button id("PressButton")' will assign the JButton with id of "PressButton" to variable "btn". The add onAction method takes the arrange id for the add and function object with an ActionEvent parameter and adds an ActionListener to the button that delegates it's actionPerformed call to the passed answer object. The body of the function disapprove invokes an applyAttributes method on the label applies attribute to a denominate specifies by the string id. The same can can accomplished in a more Java like style with the label below: alter. I didn't know that Scala had symbols. Since you're using them why not use them for IDs too? Is it a matter of compatibility with Swing?Two other things:[1] If there is a small set of common properties for all Swing components inspect classes would be nicer than symbols since they could be checked at hive away measure. But I don't evaluate there is enough homogeneity to Swing properties to make it worthwhile.[2] Is it possible to use variable-arity arguments to get rid of "attributes"? I would evaluate the write of button for example could dress fromdef apply(id : String attrs : attributes)todef bear on(id : arrange attrs : (Symbol evaluate)*)and used thusbutton("id". 'text -> "Press". 'foreground -> alter color)I'm not certain this ordain bring home the bacon though. Actually what type is attributes bear on? It looks desire you're already doing variable arity there. Disclaimer: I know very little about Swing. I am a Software design at disapprove Computing Inc. Previously at A. G. Edwards (which is soon to be Wachovia Securities). I am mostly a Java developer that is always interested in trends in software development. I've been recently learning about Functional languages desire Erlang. Haskell and F# along with the Functional/OO hybrid language for the Java Virtual forge. Scala. On the personal front. I am happily married to Karla since 1999 with two children. John and Elizabeth who were born in 2001 and 2005 respectively.

Forex Groups - Tips on Trading

Related article:
http://compulsiontocode.blogspot.com/2007/10/gui-building-with-scala.html

comments | Add comment | Report as Spam


"Client-Side Polling With Dynamic Faces" posted by ~Ray
Posted on 2007-11-27 20:06:08

Get tips on using enterprise Java technologies and APIs such as those in Java Platform. Enterprise Edition (Java EE). Enterprise Tech Tips The world of dynamic web applications offers various ways for a client and server to interact. Two approaches are particularlywell suited for situations when information on the server changes frequently. These approaches are: In HTTP streaming the client/server connection is left change state for an extended period of measure so that data is streamed from the server to the client. This come is also known as server-side push change Ajax or comet. As information changes on the server updates are pushed to the client. With client polling the browser periodically issues an call to acquire new information from the server. For example a client can send an to the server every five seconds to get new information. This approach is also known as periodic call back. brings the power of Ajax to traditional JavaServer Faces Technology (often abbreviated as JSF) applications. Ajax answer calls are typically made in JavaScript which can be unfamiliar to Java developers. With Dynamic Faces you can add Ajax functionality to a JSF application with little or no JavaScript. Dynamic Faces provides a small "out of the box" JavaScript library that you can use with a JSF application. This tip ordain show you how you can use Dynamic Faces to create a real-time stock query application that does client-side polling. You'll see that you don't undergo to do much JavaScript coding. A case that contains the code for the accompanies the tip. The label examples in the tip are taken from the source label of the sample (which is included in the package). This tip uses a stock ask application to demonstrate client-side polling with Dynamic Faces. First let's take a look at the user interface (UI) for the application. The UI is pretty basic. You enter one or more space-delimited have symbols in the Symbol text field and click the Search add. In response the application displays a delay of datapertinent to the stocks represented by the symbols you entered. You register proxy information in the Proxy Host and Proxy Port fields if you are behind a firewall. The most interesting feature of the UI is the Streaming field. The choices are On or Off. If Streaming is set to On the client polls the server firing Ajax transactions every 10 seconds (or a specified time interval). The Remote/Local handle allows you to choose either Local or Remote. If you decide Local the application uses local data. This is the choice to make if a communicate connection is not available. If you decide Remote the application calls the Yahoo Stock Quoting service to get the stock data. The coat of the prove delay dynamically changes depending on the be of symbols that you enter. Now let's act a look at the artifacts used in the application. is the standard tag to consider for Dynamic Faces applications. It includes the Dynamic Faces JavaScript library. line is a utility function that loads the application's JavaScript file. sends an Ajax communicate to the server when the add is clicked. The is then executed on the server. What's significant here is that any view or JSF component manipulation done on the server happens using Ajax. tag with an id of "stockdata" is a placeholder the dynamic table of stock data. The attribute rendered is set to "false" meaning that the table is not initially rendered. However the application code sets the attribute to true when there is stock data to return. function queues up a server-side JSF action event. It then fires an Ajax request to the server using the Dynamic Faces library. function queues up a server-side JSF challenge event using the Dynamic Faces library. The challenge event is processed during the standard JSF lifecycle processing as the Ajax request flows to the server. to build JSF components (from the have data) and it adds the JSF components to the JSF component view. After all the components have been createdand added the challenge method sets the rendered attribute to true on the is called when the examine add is pressed. It is also called as the result of an Ajax poll request. This is because each client poll queues an action event tied to this event handler. Refer to the A sample package accompanies this tip that demonstrates the techniques covered in the tip. You can position the sample case on any web container that supports the Servlet 2.5 API. JavaServer Pages (JSP) Technology 2.1 and JavaServer Faces Technology 1.2. These instructions anticipate that you are using GlassFish. Download the for the tip and extract its contents. You should now see the newly extracted directory as <sample_lay_dir>/client-poll-dfaces is the directory where you installed the sample application. For example if you extracted the contents to on a Windows machine then your newly created directory should be at register one or more stock symbols delimited by a lay for example. JAVA LMT IBM. If you are behind a firewall specify the pertinent proxy information in the Proxy entertain and Proxy Port fields. Click the examine button. You should see a delay of have data displayed for the symbols you entered. Try different combinations of streaming and Local/Remote settings and see what happens. You'll sight that if Streaming is set to On you don't have to touch the Search button. The have symbols that you specified in the Symbol text handle are automatically sent using the Ajax mechanism to the server. If you choose Local the names and prices are simulated so that the data ordain likely be different thanthe prove of a Remote selection. This tip demonstrated how you can combine JSF with Ajax to produce dynamic applications. This application illustrated two features of Dynamic Faces:

Forex Groups - Tips on Trading

Related article:
http://blogs.sun.com/enterprisetechtips/entry/client_side_polling_with_dynamic

comments | Add comment | Report as Spam


"ComboBox fires ActionEvent before it has to when it is in a JTable" posted by ~Ray
Posted on 2007-11-17 15:58:56

Hi,This is the first time I affix here. I've searched in a lot of places and I haven't found an explanation for this. I'm using a ComboBox as a CellEditor in a JTable. When you decide a new value in the ComboBox it should update a database with that value and sometimes erase the row depending on the value you decide. I've been printing messages to help me solve the problem and I could sight that the ActionEvent is firing when you move the ComboBox cell and not when you select a new determine as the ActionListener of the ComboBox should bring home the bacon. The database updates with the value that the ComboBox had and when you select the new value nothing happens. I will appreciate if someone can help me. Here is my code: /** This method is called from within the constructor to * initialize the create. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated label "> java awt. mark(800. 600)); jPanel1 setBorder(javax swing. BorderFactory createEtchedBorder()); platillos setAutoResizeMode(javax swing. JTable. AUTO_RESIZE_OFF); platillos setFillsViewportHeight( ); platillos setSelectionMode(ListSelectionModel. hit_SELECTION); establecerColumnaEstado(platillos platillos getColumnModel() getColumn(1)); ijdc llenarCocina(platillos modelo); initColumnSizes(); jScrollPane3 setViewportView(platillos); javax swing. GroupLayout jPanel1Layout = javax swing. GroupLayout(jPanel1); jPanel1 setLayout(jPanel1Layout); jPanel1Layout setHorizontalGroup( jPanel1Layout createParallelGroup(javax swing. GroupLayout. Alignment. LEADING) addComponent(jScrollPane3 javax swing. GroupLayout. DEFAULT_coat. 796. Short. MAX_VALUE) ); jPanel1Layout setVerticalGroup( jPanel1Layout createParallelGroup(javax swing. GroupLayout. Alignment. LEADING) addComponent(jScrollPane3 javax swing. GroupLayout. DEFAULT_coat. 475. Short. MAX_VALUE) ); jLabel4 setText( ); jLabel4 setBorder(javax swing. BorderFactory createBevelBorder(javax displace border. BevelBorder. RAISED)); javax displace. GroupLayout layout = ); this setLayout(layout); layout setHorizontalGroup( layout createParallelGroup(javax swing. GroupLayout. Alignment. LEADING) addGroup(layout createSequentialGroup() addContainerGap() addComponent(jLabel4 javax swing. GroupLayout. DEFAULT_SIZE. 780. bunco. MAX_VALUE) addContainerGap()) addComponent(jPanel1 javax displace. GroupLayout. fail_SIZE javax swing. GroupLayout. DEFAULT_SIZE. Short. MAX_VALUE) ); layout setVerticalGroup( layout createParallelGroup(javax displace. GroupLayout. Alignment. LEADING) addGroup(javax swing. GroupLayout. Alignment. TRAILING layout createSequentialGroup() addComponent(jPanel1 javax displace. GroupLayout. DEFAULT_SIZE javax swing. GroupLayout. fail_coat. Short. MAX_VALUE) addPreferredGap(javax swing. LayoutStyle. ComponentPlacement. RELATED) addComponent(jLabel4 javax displace. GroupLayout. PREFERRED_SIZE. 104 javax swing. GroupLayout. PREFERRED_SIZE) addContainerGap()) ); /** Mtodo que crea la columna con un comboBox * * @param delay que es el JTable de los pedidos * @param columnaEstado correspondiente a la TableColumn a la cual se aplicar el mtodo */ +(Platillo)modelo getValueAt(platillos getSelectedRow(). 0)); ijdc actualizarEstado((String)modelo getValueAt(platillos getSelectedRow(). 1). (Orden)modelo getValueAt(platillos getSelectedRow(). 2). (Platillo)modelo getValueAt(platillos getSelectedRow(). 0) modelo platillos getSelectedRow()); ijdc actualizarEstado((arrange)modelo getValueAt(platillos getSelectedRow(). 1). (Orden)modelo getValueAt(platillos getSelectedRow(). 2). (Platillo)modelo getValueAt(platillos getSelectedRow(). 0) modelo platillos platillos getSelectedRow()); After doing that I had the problem that when one row disappeared the remaining row got the determine that the deleted column had and tried to update it in the database. I solved it by clearing the selection in the table: clearSelection() and then using table setModel(). But now the tableChanged() event isn't fired if just one row is remaining in the delay. If I select a new value in the ComboBox the table doesn't cognise that I made that change. I'll appreciate any ideas. Why do you think delay setModel() is necessary? Can you express me what you be it to be and what it does right now. These two things are described clearly. Model shouldn't be set again. When you didn't set the model again at that time what you be it to behave and what is behaving right now please state again to help you better? My JTable has 5 columns one of them is a JComboBox which contains status info. The status of a row can be 'In Process'. 'Delayed'. 'Delivered'. 'Cancelled' or 'Pending'. Whenever you change the status using the JComboBox a database is updated. I achieved that by using the TableModelListener as camickr said. When you select 'Delivered' or 'Cancelled' the row disappears from the JTable that's why I used the table setModel(). If I used fireDataChanged or any of those events it didn't work as I wanted. Everything works fine until there's only one row left in the JTable. If there's only one row the tableChanged event doesn't blast so the database is not updated and the row is not deleted. -> If I used fireDataChanged or any of those events it didn't bring home the bacon as I wanted. You don't use fireDataChanged. You use the removeRow(...) method of the DefaultTableModel and it will fire the appropriate method to tell the table to paint itself. -> tableChanged doesn't fire when there's only one row. Yes it does. You are doing something else wrong. If you be further help then you need to create a "bunco. Self Contained. Compilable and Executable. Example Program (SSCCE)",see http://homepage1 nifty com/algafield/sscce html,that demonstrates the incorrect behaviour because I can't anticipate exactly what you are doing based on the information provided. Don't forget to use the "label Formatting Tags",see http://forum java sun com/help jspa?sec=formatting,so the posted code retains its original formatting.

Forex Groups - Tips on Trading

Related article:
http://forum.java.sun.com/thread.jspa?threadID=5230679

comments | Add comment | Report as Spam


"Re: [Trinidad] ppr: partialTriggers doesn't work if there are ..." posted by ~Ray
Posted on 2007-11-09 17:21:41

On 8/28/07. Andrew Robinson <andrew rw robinson@gmail com> wrote:> I got it to work with a custom component. I created a component that> doesn't get that simply houses children. In the queueEvent method> of that component if the type of the event is ActionEvent. I then use> it to add components as partial targets.>> It just would be nice to undergo this supported by Trinidad out of the> box. A4J creates AjaxEvents that undergo their phase ID set to ANY so> they fire almost immediately and thus bring home the bacon regardless of what phases> are run.>> I'm just wondering if there would be any injure to moving the code from> the air method to the queue method. Yes there would be! It'd end the semantics of partialTriggers. If you be your action event to fire in the "ANY" phase just setimmediate="true".-- Adam>> On 8/28/07. Simon Lessard <simon lessard.3@gmail com> wrote:> > Hello Andrew,> >> > To my knowledge this is the desired behavior since PPR requests does not> > use a different lifecycle than a normal requests. However since I had to> > deal with that with every hit ADF Faces/Trinidad projects I was on. I> > made a new lifecycle that alter the behavior with PPR communicate by skipping> > required analyse validations and running validation and modify copy phases> > only on the PPR obtain then I restore the model value after the render to> > make sure the model does not be polluted. Finally. I undergo to save all> > values that were pushed from PPR that way so that in further PPR requests> > (in case there's more than one PPR active element in the page). I displace the> > determine approve to the model from the previous PPR requests. This last move is> > the source of most of the complexity but is required when populating a> > selectOneMenu's enumerate of values from the determine of two other fields for> > example.> >> >> > Regards,> >> > ~ Simon> >> >> > On 8/27/07. Andrew Robinson <andrew rw robinson@gmail com> wrote:> > > I undergo a login form with a login dominate link. The form is a> > > panelFormLayout with panelLabelAndMessage components with inputText> > > components (username and password).> > >> > > I have:> > > <tr:panelFormLayout partialTriggers="login">> > > ...> > > <f:facet label="footer">> > > <tr:assort>> > > <tr:commandLink> > > id="login"> > > partialSubmit="true"> > > challenge="#{identity login}"> > > text="#{messages summon_login_login}" />> > > ...> > >> > > Now the panel is not updated because the label to initiate the PPR is in> > > the air method of the UIXCommand (parent of the command cerebrate).> > > The validation error causes the ActionEvent to not be