Home | Community | Message Board

Kratom Eye
This site includes paid links. Please support our sponsors.


Welcome to the Shroomery Message Board! You are experiencing a small sample of what the site has to offer. Please login or register to post messages and view our exclusive members-only content. You'll gain access to additional forums, file attachments, board customizations, encrypted private messages, and much more!

Myyco.com Shop: Golden Teacher Liquid Culture For Sale

Jump to first unread post Pages: 1
Java Help
    #12599840 -

ok i dunno what is going on, i kinda know i'm overlooking something but i just can't find what it is. I need another set of eyes, and its probably staring me right in the face!

Code:

try{

BufferedReader br = new BufferedReader(new FileReader("shoppinglist.txt"));
String strline;
while ((strline = br.readLine()) != null){
String[] splitstr;
splitstr = strline.split("-");
name = splitstr[0];
number = splitstr[1];

Items item = new Items(name, number);
itemsList.add(0, item);
}

br.close();
}

catch (Exception e){
System.out.println(e.toString());
}


Where itemsList is a List within a ListView control.

The array (splitstr[]) appears to be empty because if i try this outside of the try {} catch{}
Code:
Items item = new Items("Apples","3");
itemsList.add(0, item);


Then Apples 3 is displayed in my ListView fine
So the problem appears to be within the reading of the file or string as the Items class and itemList object are functioning as they should. i'm confuzzled as since i can't output to console (from within this wicket framework setup), i can't see if any exceptions are being thrown.

shoppinglist.txt:
Code:
batman-1
milk-2
bread-5



The file "shoppinglist.txt" is in the applications root directory.


--------------------
All are lunatics, but he who can analyze his delusions is called a philosopher. - Ambrose Bierce

Extras: Filter Print Post Top
Re: Java Help [Re: flangenips]
    #12599899 -

You didn't really explain what the problem is, or how you know there is a problem, you just explained why the problem might be taking place.  I can't see any syntax errors, but if you cannot print to the console, you might try writing the exception message to a file.


--------------------

Extras: Filter Print Post Top
Re: Java Help [Re: Smitington]
    #12599972 -

I also tested the code myself, and found no errors, so from what I can tell your file isn't being found (or your item/itemsList stuff doesn't work):

import java.io.BufferedReader;
import java.io.FileReader;


public class test
{

static public void main(String [] args)
{

try
{            
            BufferedReader br = new BufferedReader(new FileReader("shoppinglist.txt"));
            String strline;
            while ((strline = br.readLine()) != null){
                String[] splitstr;
                splitstr = strline.split("-");
                System.out.println(splitstr[0]);
                System.out.println(splitstr[1]);
            }
           
            br.close();
        }

        catch (Exception e){
            System.out.println(e.toString());
        }
}

}

System output:

batman
1
milk
2
bread
5


--------------------

Extras: Filter Print Post Top
Re: Java Help [Re: Smitington]
    #12600066 -

Smitington said:
You didn't really explain what the problem is, or how you know there is a problem, you just explained why the problem might be taking place.  I can't see any syntax errors, but if you cannot print to the console, you might try writing the exception message to a file.



oops sorry, the problem is that i can't populate the itemList with the strings in the array as something is going wrong. Though i feel the syntax is fine.

Ill try output the exception to file cheers.


--------------------
All are lunatics, but he who can analyze his delusions is called a philosopher. - Ambrose Bierce

Extras: Filter Print Post Top
Re: Java Help [Re: flangenips]
    #12600261 -

hmm ok can't even output to file conventionally in my class i'm using this... i've tried this in the base application class, a seperate plain java class, same result.

Can't get System.out.prinln() to print anything in my output window. It doesn't throw any exceptions. from any of the classes in this framework. this is boggling. It just wants nothing to do with input and output. Wicket normally

btw. This is just a piece of a web-application. I can easily display add, remove, even clear the list view using a gui view i've created in firefox. So the Items class and ListView are operating correctly.

And normally wicket outputs all exceptions to the browser and the application does not run at all, but in this case it just runs as normal, with an unpopulated listView :mad2:

When I add things to the list view via my gui, or manually in code, they populate and I can see this when i run the application.

Hmm maybe ill re-do my code, allow the list to persist between runnings. But only allow make additions to the list with a save button, but have the option to add to the list graphically before saving. (i need to do this for my task!!) hmmm, this is going to require more html and lines of code. ghey.


--------------------
All are lunatics, but he who can analyze his delusions is called a philosopher. - Ambrose Bierce

Extras: Filter Print Post Top
Re: Java Help [Re: flangenips]
    #12600699 -

hmm nevermind sorted it out. Not using inputs and outputs anymore, just persisting the listview without versioning (so it persists between tests after changes). Created second list view to graphically show additions to the list, which automatically clears on startup and when user saves, and adds to the main list view to persist (before it clears)

Would've liked to use a file for fast editing like i wanted to with the string splitter.

Not as handy, but it will do.


--------------------
All are lunatics, but he who can analyze his delusions is called a philosopher. - Ambrose Bierce

Extras: Filter Print Post Top
Re: Java Help [Re: flangenips]
    #12601968 -

nvm

Edited by teknix (05/21/10 12:56 AM)

Extras: Filter Print Post Top
Re: Java Help [Re: teknix]
    #12614722 -

arggh now i'm having issues integrating javascript into my web application. When i put the code in my <head></head> tag thats fine, when i call it thats fine. It just doesn't work on deployment to apache tomcat for testing.

If i use ajax instead to pass the javascript to the webpage using scriptaculous javascript library:
I get Error: Effect not defined in the Wicket Ajax debug window.

but the scripts are there, NetBeans autocomplete works for it, so its not like its 'not defined!!'
the error does not affect the actual function of the components (i.e add/deleting items from a ListView, setVisible(true/false) on a form)

is there something i need to include in my web.xml file to implement javascript? I wouldn't have thought so since NetBeans provides support, and most browsers support javascript/ajax!

heres a snippet of the head when trying to use scriptaculous
Code:

<head>
<title> The eGrocery </title>
<script src="/javascripts/prototype.js" type="text/javascript></script>
<script src="/javascripts/scriptaculous.js" type="text/javascript></script>
</head>


I repeat, the src is correct, because when its not, Autocomplete on Effect.[AutoCompletefunction](); wouldn't come up in netbeans.

and example of ajax i used
dependencies are fine, link displays, javascript does not execute: "Effect not defined" error in debug.
Code:

add(new AjaxLink("ajaxLink"){
public void onClick(AjaxRequestTarget target){
target.appendJavascript("new Effect.Fade('divFade');");
ItemsForm.setVisible(true); /// this part works at least so application still functions
}
});


where 'divFade' is the id: <div id="divFade">content here</div>

I also have the wicket jar libraries for scriptaculous support. So i'm a little lost.
I even tried copy and pasting source from online examples to no success, so something is missing from my deployment configuration to get it working. Any ideas?

Edited by flangenips (05/23/10 03:42 PM)

Extras: Filter Print Post Top
Re: Java Help [Re: flangenips]
    #12614970 -

bah this is what happens when you take business-based software development papers that focus mainly on database applications, file outputs and other business application, and you try making a fancy web application with little experience in a framework that has little support documentation.

This is for a task for an interview process btw. The framework was the main requirement (they expected most applicants have not used it) I've had to submit it today as is, its fully functional, just doesn't have the fancy effects which they wanted (code is there for effects, does nothing). So fingers crossed.

It should be noted that this would be easier for me using C# ASP.net and js! bah. But wicket and java were the requirements.


--------------------
All are lunatics, but he who can analyze his delusions is called a philosopher. - Ambrose Bierce

Edited by flangenips (05/23/10 04:14 PM)

Extras: Filter Print Post Top
Re: Java Help [Re: flangenips]
    #12615443 -

Sorry man, not a huge web developer, so I can't really help you too much.  Maybe you should try an actual web developers forum lol.


--------------------

Extras: Filter Print Post Top
Re: Java Help [Re: Smitington]
    #12615512 -

done that too, haven't found much help. People have even copied my source and got it going themselves, but under different servers. too bad tomcat is a requirement. It must be able to be done since it was set in this task. :/


--------------------
All are lunatics, but he who can analyze his delusions is called a philosopher. - Ambrose Bierce

Extras: Filter Print Post Top
Re: Java Help [Re: flangenips]
    #12622907 -

Code:

<head>
<title> The eGrocery </title>
<script src="/javascripts/prototype.js" type="text/javascript></script>
<script src="/javascripts/scriptaculous.js" type="text/javascript></script>
</head>



Do you really mean to be leaving off the closing quotes on your type?...


<head>
<title> The eGrocery </title>
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script src="/javascripts/scriptaculous.js" type="text/javascript"></script>
</head>

Extras: Filter Print Post Top
Re: Java Help [Re: supra]
    #12623869 -

nope that was just typo, didn't cut n paste lol


--------------------
All are lunatics, but he who can analyze his delusions is called a philosopher. - Ambrose Bierce

Extras: Filter Print Post Top
Jump to top Pages: 1

Myyco.com Shop: Golden Teacher Liquid Culture For Sale


Similar ThreadsPosterViewsRepliesLast post
* Java exploits and computer safety BothHands 970 10 09/15/12 04:34 PM
by BothHands
* Absolute Java/HTML basics.. Bugzy 440 3 10/21/09 07:13 PM
by Idiot
* whats a good programming language after java/c(++)?
( 1 2 3 all )
smoothrider267 3,287 47 07/23/09 10:47 AM
by gilesypopper
* Learning Java
( 1 2 all )
shroominliketruman 1,337 21 09/14/10 11:35 PM
by citricacidx
* super simple java help needed please mayfly 984 11 01/23/08 01:02 PM
by Annom
* Javascript errors, in both IE & Firefox. Any ideas?? mushroomhunter10 819 11 09/18/09 08:28 PM
by mushroomhunter10
* my simple programming questions thread (javascript + html) stefan 748 3 04/28/08 04:43 PM
by stefan
* question about enabling java script in google chrome imachavel 307 1 07/10/12 01:34 PM
by imachavel

Extra information
You cannot start new topics / You cannot reply to topics
HTML is disabled / BBCode is enabled
Moderator: trendal, automan, Northerner
713 topic views. 0 members, 2 guests and 2 web crawlers are browsing this forum.
[ Show Images Only | Sort by Score | Print Topic ]
Search this thread:

Copyright 1997-2026 Mind Media. Some rights reserved.

Generated in 0.032 seconds spending 0.008 seconds on 16 queries.