Joel Jorgensen

Greenhorn
+ Follow
since Oct 13, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Joel Jorgensen

When you do a selection using $ and get several nodes and then do something to act on those nodes, such as

behind the scenes does it basically just run a loop and iterate over each of those items and invoke the method on each of them (similar to using the map function in Clojure), or is there something more complicated going on?

Thanks,
Joel
Is there a CLDC version/configuration of the J2ME (or even J2SE) that would be able to run on a 16-bit MS-DOS machine? The documentation that I've been able to find hasn't been clear--one thing said it only runs on Palm OS 3.01, something else said that it was portable across all 16-bit architectures. I haven't been able to find anything that says specifically "This version is for 16-bit MS-DOS systems" but maybe I am just not looking in the right places.
16 years ago



For starters, it looks like your debugging code may not be showing you what you think it is; it looks like you are actually retrieving the values for PlayerGold 0 and PlayerGold 1 from the exact same place: pD.Invent(pD.playerNum)[gV.GOLD]

Since (as far as I can tell) you do not change pD.playerNum between those two System.out.println() statements, it makes sense that they are printing out the same value. If I'm understanding it correctly, you'll need to fix that before you can say for sure whether the pD.InventAdd() method call is doing what you want it to do.
17 years ago
The c:forEach tag also allows you to track the status of the loop if you use the "varStatus" attribute (e.g. varStatus="charGroupStatus"). You can then use c:if tags to check whether the index is 0 (i.e. whether it is the first time through the loop) and print out the cells accordingly.

Like so:

This might not be the most efficient way to do it (because it does the two if checks for every single modelChar), but it seems readable and doesn't involve slightly unsual </tr> <tr> pairs (which the other solution that I thought of would require ;) ) and as long as you don't have thousands upon thousands of modelChars you can probably get away with it
17 years ago
JSP
I think this happens because && and || are "short circuit" operators, so the JVM takes the path that will allow it to resolve the expression the fastest. The reasoning may sound a little backwards, but I'll do my best to keep it straightforward:

JVM sees (a = true) || (b = true) && (c = true)
JVM recognizes && has higher precedence, so re-groups expression like this: (a = true) || ( (b = true) && (c = true) )
JVM realizes that if first operand (a = true) is true it can skip everything else, so it checks that first. It turns out that it is true, so JVM skips the evaluation of the remaining operands since (as far JVM is concerned) they would have no impact on the outcome and evaluating them would be a waste of cycles.

So for short-circuit operators the precedence of && means that ((b = true) && (c = true)) will be evaluated as the right-side operand of the || if it is needed to determine the outcome, not first.

In the same vein, if you had the following code:

The final values would be
a: false
b: false
c: false

Even though the parenthesis on the right side have higher precedence than && their contents won't be evaluated because they don't need to be.

I hope that helps, but if you'd like me to clarify something I said here (or if I got something dead wrong!) please let me know
17 years ago
I'd strongly recommend making an Ajax request to the Controller, with the value of Text1. Configure the Controller so that it will pass the Text1 value to the Model, which should then verify whether the Text1 value is in the database and return true or false to the View.
[ January 08, 2007: Message edited by: Joel Jorgensen ]
I'd strongly recommend making an Ajax request to the Controller, with the value of Text1. Configure the Controller so that it will pass the Text1 value to the Model, which should then verify whether the Text1 value is in the database and return true or false to the View.
[ January 08, 2007: Message edited by: Joel Jorgensen ]
17 years ago
JSP
When I am trying to figure out how to express something algorithmically, I often find it helps for me to write out what I think it does in language that I am most familiar with (sort of like pseudo-code) with gaps to be filled in later for the parts that I'm not sure about.

You say that you can sort of see what d is doing--what is it that you can see, and where are the gaps that you can't see yet?
17 years ago
Not sure whether this will help with your larger problem of getting an error when you make the request, but most of the things that I have read about Dojo say that you should have your dojo.require() statements all in a separate block of script from the actual functions, like this:


As far as debugging the error that you're getting, nothing is really jumping out at me as being incorrect about your code. This is probably a silly suggestion on my part, but are you certain that the Ajax call is getting to the proper JSP on the server? If so, then I'd recommend putting some extra code in the JSP to see what exactly it is sending back, and putting some code in your handler method in the Javascript to actually see what is in the type, data, and evt variables (especially type and data). This might help give you some clues as to what's going wrong and where.
[ January 08, 2007: Message edited by: Joel Jorgensen ]
Thanks for the suggestions Eric I ended up using a modification of your first one: I use an AJAX method to post the data to the server, where I then store it in a session attribute. Once that is finished, the client opens the new window, which calls the servlet to generate the image. That servlet gets the data from the session attribute, generates the image, and returns it to the page for display.

Originally posted by Henrik Engert:
Hi again,

I guess what I am asking is the following:

If I use the following code:



and I don't create a person to set with request.setAttribute("person", p);

I would think I would get Fred as a result.....

[ January 08, 2007: Message edited by: Henrik Engert ]

[ January 08, 2007: Message edited by: Henrik Engert ]



In this case, the problem is that you are not specifying a 'class' attribute for the new bean to have. It tries to cast it to be type com.example.model.Person, but without a 'class' attribute it doesn't know what class to use to create the new bean. If you add a class attribute of com.example.model.Person, it should resolve your null pointer exception problem (or at least get you closer
[ January 08, 2007: Message edited by: Joel Jorgensen ]
17 years ago
JSP
The "code" between of the <jsp:useBean> and </jsp:useBean> tags only gets evaluated if there is no bean of the specified class in the specified scope. This may not be the best analogy, but I tend to think of it as sort of a constructor for the bean if it isn't there. I suspect that in your case the bean is there, but that particular property of the bean is null. So the code to populate that property does not get evaluated (the bean already exists, so the conditional "creation" code between the jsp:useBean tags isn't executed).

I recommend looking into Expression Language (EL) and the JSTL core library tags for conditionals that you can use to see whether the property has been populated or not. There may be other ways to do it as well (especially if you're using Struts), but I'm a huge EL fan (it generally seems much tidier and more intuitive to me as a programmer) so that's what I'm recommending
[ January 05, 2007: Message edited by: Joel Jorgensen ]
17 years ago
JSP
This worked for me--the upper 5% of the page was blue, the middle 90% was yellow, and the bottom 5% was purple. It's actually a little too big for some reason, but if you just tweak the values down one or two percent in each case that should take care of it. (I tested in FireFox 1.5.0.9 and IE 6)

I have an application that gets dynamically generated images from a servlet. Currently the client's Javascript uses a window.open() call with a URL that has a query string appended with the parameters that the server should use to generate the image and the whole thing gets sent as a GET request to the server. However, recent changes to the requirements now require the client side Javascript to create a (potentially lengthy) list of items that it wants to be included in the image, so continuing to use a GET request is not an option.

Is there some way to open a new browser window but have it send a POST request to the server?

If not, is there some way to do this with AJAX (e.g. send an asynchronous POST request, get the response as an 'image/jpeg', open a new browser window, create a new image element within that browser window, and use it to display the image sent from the server)?
This may not be quite what you're looking for, but if you hide the overflow it won't wrap. The potential problem with this is that you will probably also need to explicitly set the width and height of the element (otherwise it will collapse completely) e.g.


There may also be a way to set just the horizontal overflow (elem.style.overflowX, maybe) in which case you would only need to specify the width, e.g.

[ January 04, 2007: Message edited by: Joel Jorgensen ]