|
Have two css classes for the Nav links; code:
onload Set all links cssClass="there" look at the current page and which ever link it matches set the cssClass="here" I am sure there is a better way, but that jumped out at me.
|
# ? Oct 17, 2008 01:08 |
|
|
# ? May 11, 2024 12:08 |
|
magnetic posted:Have two css classes for the Nav links; You mean doing it in javascript? I would rather there be no flicker or anything like that. I feel like there should be a way to standardly pass a bean in the scope of the parent page to the code in the included page, but I can't figure out how to do that. Whenever I try to use <bean:define> in the parent page and use it in the included page, I get errors saying that the bean does not exist in the included page. I thought that <jsp:include>s just basically copied and pasted the text into the place where the tag is used, but I guess it doesn't.
|
# ? Oct 17, 2008 01:38 |
|
sonic bed head posted:You mean doing it in javascript? I would rather there be no flicker or anything like that. I feel like there should be a way to standardly pass a bean in the scope of the parent page to the code in the included page, but I can't figure out how to do that. Whenever I try to use <bean:define> in the parent page and use it in the included page, I get errors saying that the bean does not exist in the included page. I thought that <jsp:include>s just basically copied and pasted the text into the place where the tag is used, but I guess it doesn't. <jsp:include> can take arguments, though; so you can do something like this: code:
For what it's worth though JSP is probably the worst templating engine ever (other than perhaps "PHP", to which it is very similar), the XML-based version makes it only marginally better, and this sort of pain will haunt you until you stop using it.
|
# ? Oct 17, 2008 11:55 |
|
zootm posted:No, they don't. That's what the include directive does but the directive stuff is very old-school and sucks a whole lot; don't use it.
|
# ? Oct 17, 2008 14:30 |
|
TRex EaterofCars posted:While JSP by itself is definitely poo poo to use, do you really think JSP with JSTL and EL is that bad?
|
# ? Oct 17, 2008 17:42 |
|
zootm posted:Yeah. It bugs the crap out of me. JSTL and EL make it infinitely better, though, especially once you can externalise your own stuff out into custom taglibs. Can I ask what you prefer using?
|
# ? Oct 17, 2008 18:31 |
|
TRex EaterofCars posted:Can I ask what you prefer using? In seriousness though, most other things are better, although I've not too much experience with the Java ones. I hear really good things about Tapestry and Wicket, though, and I quite liked Lift's templating the last time I played with it, although that's Scala rather than Java. zootm fucked around with this message at 20:15 on Oct 17, 2008 |
# ? Oct 17, 2008 20:12 |
|
Wicket is excellent. I haven't personally used Tapestry, but in my opinion, Wicket is more community driven. Tapestry is controlled by just one guy. And I hear he's a douche.
|
# ? Oct 17, 2008 20:20 |
|
I'm having a very newbie problem with NetBeans. I'm learning Java, and have just reached the point in my book that discusses the ImageIcon class. The following is the code I'm typing in: code:
What I think is happening, is that I'm not putting the file "pumpkin.jpg" in the correct location. I've been putting it in the src folder, and I tried putting it in the same package as main.java but it still doesn't show up. I guess what I'm asking is. Where should I stick this?
|
# ? Oct 19, 2008 10:59 |
|
Try it using the full path, like "C:\\Images\\pumpkin.jpg" (or whatever) if you're on Windows. I think if you don't it needs to be in the same directory as the .class file (bin?)
|
# ? Oct 19, 2008 11:08 |
|
If you just give a filename like that, it'll be interpreted relative to the process current directory, which is determined in some system-dependent way. If you're launching from an IDE, it should be one of the standard options, and it probably defaults to the project directory. If you're running from a command line, it's whatever directory you're in when you launch Java. If you want to fetch something relative to the path that a class is stored in, use Blah.class.getResource(filename), which will give you a URL. rjmccall fucked around with this message at 13:21 on Oct 19, 2008 |
# ? Oct 19, 2008 13:19 |
|
I'm trying to learn some Java, and I've started by playing with Sun's tutorials. I've gone through the example at http://java.sun.com/docs/books/tutorial/java/IandI/subclasses.html and implemented it as written. To better understand it, I'm trying to write a simple program that implements the class/subclass but I'm having trouble when it comes to creating an instance of the subclass. What am I doing wrong? This is how I'm trying to create a MountainBike. code:
code:
|
# ? Oct 19, 2008 19:16 |
|
what does your bicycle and mountainbike code look like?
|
# ? Oct 19, 2008 19:52 |
|
crm posted:what does your bicycle and mountainbike code look like? Basically the same as in sun's example: code:
|
# ? Oct 19, 2008 19:55 |
|
Oh. You've placed your MountainBike class inside the Bicycle class, which I assume is not what you meant to do. Put the MountainBike class in its own separate MountainBike.java file and try again.
|
# ? Oct 19, 2008 22:26 |
|
Mill Town posted:Oh. You've placed your MountainBike class inside the Bicycle class, which I assume is not what you meant to do.
|
# ? Oct 20, 2008 00:44 |
|
There's no standard library for fast fourier transforms, is there? I need to write a program to do some audio analysis and I haven't used Java since version 2, so if anyone can reccomend a good library it would help out a lot.
|
# ? Oct 20, 2008 05:27 |
|
I've been trying to avoid actually writing any code for this cryptography class I'm in but alas, I actually have to, and now my avoidance of programming has bitten me in the rear end. I'm trying to implement RSA in java and it won't let me write functions: import java.math.BigInteger; BigInteger RSAencrypt(BigInteger exponent, BigInteger modulus) {return this.modPow(exponent, modulus);} won't compile. Anyone know what's up?
|
# ? Oct 21, 2008 02:05 |
|
Bill O'Riley is GENIUS posted:I've been trying to avoid actually writing any code for this cryptography class I'm in but alas, I actually have to, and now my avoidance of programming has bitten me in the rear end. I'm trying to implement RSA in java and it won't let me write functions: Functions have to be inside objects in Java. You can't have them sitting around on their own. If it's not a function that does something to an object, you can use the static keyword to make it a class method instead of an instance method, like so: code:
Edit: judging by that this.modPow you have in there, you should probably change modPow to a static method too and remove the this. Actually it's not very clear what you are trying to accomplish here. Can you post the code in its entirety, the actual error you get when you try to compile, and a summary of what you think your code is actually doing? Mill Town fucked around with this message at 03:39 on Oct 21, 2008 |
# ? Oct 21, 2008 03:34 |
|
Mill Town posted:Functions have to be inside objects in Java. You can't have them sitting around on their own. Thanks. Can someone direct me to a better programming language that supports large integers and lets me define whatever kind of functions I want? I think it's way too big of a pain that I have to define a class just to define functions on a pre-existing class. I know C++ lets you do this but it doesn't support large enough integers. Starving Autist fucked around with this message at 03:42 on Oct 21, 2008 |
# ? Oct 21, 2008 03:38 |
|
Bill O'Riley is GENIUS posted:Thanks. Can someone direct me to a better programming language that supports large integers and lets me define whatever kind of functions I want? There's no reason you can't implement this properly using objects. Implying that a language is "worse" for insisting on an object-oriented structure is... wrong. Rather than flame you, though, I'm going to recommend python. It's a scripting language, meaning there's no compiling, which is nice for quick-n-dirty projects like this, it doesn't insist on objects, and it has bigint support built in.
|
# ? Oct 21, 2008 03:43 |
|
I have a real quick question. I'm writing a Java program for an address book and I need to be able to modify an entry in the database where it will overwrite what's saved now with whatever the user enters to replace it with but if the user just hits enter it doesn't overwrite anything and just leaves the current value in. In short, how can I read that a user just hit enter from the keyboard so I can tell it to leave the current value rather then overwriting the variable with a blank space? Thanks Edit: Another thing, is there a good way to write nodes to files, like from a binary tree? Startacus fucked around with this message at 07:27 on Oct 21, 2008 |
# ? Oct 21, 2008 06:35 |
|
Bill O'Riley is GENIUS posted:Thanks. Can someone direct me to a better programming language that supports large integers and lets me define whatever kind of functions I want? I think it's way too big of a pain that I have to define a class just to define functions on a pre-existing class. I know C++ lets you do this but it doesn't support large enough integers. Alternatively you can run .scala files in an interpreted mode that'd let you do something like this, but unless you're just hacking something together you'd be better structuring your code properly in most languages. Edit: Actually there's no real harm in doing this sort of thing in Python as Mill Town suggests.
|
# ? Oct 21, 2008 09:08 |
|
Startacus posted:I have a real quick question. I'm writing a Java program for an address book and I need to be able to modify an entry in the database where it will overwrite what's saved now with whatever the user enters to replace it with but if the user just hits enter it doesn't overwrite anything and just leaves the current value in. In short, how can I read that a user just hit enter from the keyboard so I can tell it to leave the current value rather then overwriting the variable with a blank space? Hm, this sounds suspiciously like a homework question. I'll just say that you can use the equals method on a string object to check that it's equivalent to something (for example, a blank string).
|
# ? Oct 21, 2008 11:03 |
|
zootm posted:There's bound to be a BigInteger library for C++ if you really must drop two lines of code and encapsulation. Making things attached to classes is one of the better decisions in the design of Java, though; I'm pretty sure a "better" language isn't really what you want. Yeah but I have no idea how to use others' code, every time I have tried it has ended in horrible failure and my compiler hates me.
|
# ? Oct 21, 2008 15:07 |
|
Startacus posted:Edit: Another thing, is there a good way to write nodes to files, like from a binary tree? The topic you want to Google for is called Serialization. Preferably, serialization to XML. Like someone else said, this sounds like homework, so I'm just going to point you in the right direction.
|
# ? Oct 21, 2008 16:20 |
|
Yea, this is for a homework problem but I figured both of them out. The writeObject method actually let me just write the entire node to a file and then I just used the .equals on a string to determine if it was null. Thanks for the help.
|
# ? Oct 21, 2008 17:00 |
|
Mill Town posted:Hm, this sounds suspiciously like a homework question. speaking of blank strings, why did it take until 1.6 for Sun to implement isEmpty() on Strings?
|
# ? Oct 21, 2008 23:23 |
|
Working on an assignment for school I needed to create a program that would add the digits of a number until it was only one character long (88 > 16 > 7) when I came up with this:code:
|
# ? Oct 22, 2008 00:28 |
|
Capc posted:It seems to work, but looks a little sloppy. Is there a better way of writing this? For instance, is there a way to determine the amount of characters in an int without converting it to a string? If you're talking about the base 10 string you can get the number of characters in an int by dividing it by 10 until it's zero. This seems to work: code:
|
# ? Oct 22, 2008 02:27 |
|
Anyone know any good mapping library out there for java? For a project at work I'm going to feed some longitude/latitude/height data along with other data for that point, say air temperature. Going to want graph the data out as a topography, both 2D and 3D. Think something that looks like a dobbler radar. Really doubt there is anything out there, just thought I would give it a shot.
|
# ? Oct 22, 2008 04:47 |
|
crm posted:speaking of blank strings, why did it take until 1.6 for Sun to implement isEmpty() on Strings?
|
# ? Oct 22, 2008 09:05 |
|
zootm posted:Whoa, I didn't even realise that'd been done! Thanks. It's surprising how quickly "".equals( str ) gets ingrained in your head as being synonymous. "".equals( str ) is NullPointer proof though, isn't it?
|
# ? Oct 22, 2008 12:19 |
|
sonic bed head posted:"".equals( str ) is NullPointer proof though, isn't it? Yea because "" isn't technically null, it's just empty.
|
# ? Oct 22, 2008 14:37 |
|
Yeah, str.isEmpty() will fail when str is null. You should be using @Nonnull and @CheckForNull annotations to check for that stuff though
|
# ? Oct 22, 2008 16:18 |
|
Most of the time when I write stuff, I treat a null string and empty string as the same thing. That is, it's the exception more than the norm that null and empty are distinguishable to me (but these days I'm not doing any SQL stuff, so I imagine that's the real reason to distinguish typically). And really, an annotation for that? Wouldn't a straight-up method call to some static isNullOrEmpty method be faster anyway?
|
# ? Oct 22, 2008 17:38 |
|
This seems to work:code:
Editx2: Quick explanation: The trick here is in realizing that you don't need to count all the digits in the string for your inner loop, you just need to loop until you run out of digits to add. How do you know when you've run out of digits? When runSum is zero, you know you've divided away all its digits! Mill Town fucked around with this message at 18:45 on Oct 22, 2008 |
# ? Oct 22, 2008 18:40 |
|
necrobobsledder posted:Most of the time when I write stuff, I treat a null string and empty string as the same thing. That is, it's the exception more than the norm that null and empty are distinguishable to me (but these days I'm not doing any SQL stuff, so I imagine that's the real reason to distinguish typically). necrobobsledder posted:And really, an annotation for that? Wouldn't a straight-up method call to some static isNullOrEmpty method be faster anyway? They are a little verbose from time to time, but I like them. I was mostly joking with that suggestion, though. And something like an actual non-nullable type would be preferable.
|
# ? Oct 22, 2008 21:02 |
|
zootm posted:Well, I do think there is a world of difference between an empty string and a null string; if there's not, you're probably using a String for something that you shouldn't be. I do web development and I almost always treat them as the same thing, especially in situations where the string is some HTML snippet that will get printed to the page. For instance, if your string is the inner text of some table cell, you probably don't want "null" to end up in there. Or if your string is the CSS class name of the table cell, you probably want both null and the empty string to have your method generate <td> rather than <td class=""> or worse <td class="null">.
|
# ? Oct 22, 2008 23:36 |
|
|
# ? May 11, 2024 12:08 |
|
Save the whales posted:I do web development and I almost always treat them as the same thing, especially in situations where the string is some HTML snippet that will get printed to the page. For instance, if your string is the inner text of some table cell, you probably don't want "null" to end up in there. Or if your string is the CSS class name of the table cell, you probably want both null and the empty string to have your method generate <td> rather than <td class=""> or worse <td class="null">. In seriousness I can see where this is inconvenient (Java for web programming can be a pain just because you don't tend to want to be so strict with definitions), so that makes some sense. But when you're writing code which does something less trivial than constructing a website from a template the semantic distinction is more important, and the difference between an empty string and a null value is more likely to be caused by a bug than anything else.
|
# ? Oct 23, 2008 11:03 |