~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A few points:

• Class names should begin with an uppercase character. Following the Java coding conventions is a must considering you are developing enterprise applications using J2EE which itself needs you to follow rigorous coding practices.

• Comments in java begin with // or /* and not # as in Python.

• By returning an array you lose the flexibility provided by collections API and needlessly end up creating a copy of the data in the List, a bad thing. Looks like a case of premature optimization.

But if you still need it, try something like:

public TestClass[] dbFunction()
{
    int size = -1;
    TestClass arr[] = null;
    List aList = new ArrayList<TestClass>();
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    try
   {
        ps = conn.prepareStatement("select * from testTable");
        rs = ps.executeQuery();
        while(rs.next())
        {
            aList.add(new TestClass(rs.getString(1)));
        }
        size = aList.size();
        if(size > 0)
        {
            arr = new TestClass[size];
            aList.toArray(arr);
        }
    }
    catch(SQLException e)
    {
        //do some exception handling
    }
    finally
    {
        //close everthing, general cleanup
        return(arr);
    }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I am sure that these kids have no choice considering it's the Universities which force them to use ancient compilers and libraries. A real pity.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

But in return of all this you get flexibility, the ability to change the logic without sifting through 6000 lines of your markup. Plus the load times would be less than or at the most equal to the time taken to set onclick on 6000 links by hardcoding them.

I guess this is one of those choices the OP would have to make based on his requirements.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Or better yet to put a piece of code in 'onload' which loops through all the links or links based on a given class and just attach a function to the 'onclick' event handler if what he needs is a common or almost common behavior for those links...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Gamers' ahoy!!

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Like you said, since 'href' isn't an event handler I wouldn't have much faith in the first approach and I have never seen it being used in a professional environment.

The same issue occurs with the second approach since you end up calling a function inside the 'href'. A better way would be to use :

<a href="#" onclick="myFunction();">Take me away</a>

> unsure which is taking up more of my processor by dynamically creating onclick events
Profiling your application is the way to go here.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
<div style='font: normal 12px verdana; color: brown;'>
Welcome<span id="firstName">Tommy</span>
</div>

Access the contents of non-form elements(span and div) using the ' innerHTML ' property. Something like document.getElementById('firstName').innerHTML > And the funny thing is as soon as i press "t" or "T" it gets executed.
You need to show me the event handling code.

> var a = document.getElementById('header'); > document.write(a.value); Again the same mistake. Access the inner HTML of a non-form element using the ' innerHTML ' property. Something like alert(a.innerHTML).

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> my greatest weakness is my lack of creativity.
No one lacks creativity, it's just misplaced...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I guess you are talking about the 'Prototypejs' framework. In that case, please visit the forums / getting started section there to get better help, specifically this section.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Also, JavaScript has no way to read server files
Not entirely true. You can read an XML file on the server using the XML DOM API. But this applies for only valid XML files.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Use the 'onload' event handler for this task. This way, as soon as the document / body is loaded, the button will be in disabled state.

<html>
<head></head>
<body onload="funcToDisable();">
</body>
</html>

Here the 'functionToDisable()' will contain the action which you need to perform when the document loads.

That all being said, you should realize that the HTTP is a stateless protocol so you can't keep the button enabled on the first try and disabled on all consecutive reloads since there is way of knowing it. Your best bet would be to keep a flag at the server which will keep track whether its the users' first visit or not and act accordingly.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

We are really happy to hear that after two months of this threads' inactivity... ;-)

Duki commented: HAHAHAHAHHAAHHAHAHAHHAHAAHAHAHAHAHAHAHAHAHAAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA LOLOLOLOLOLOOLOLOLOLOLOLOLOLOLOLOL +4
Rashakil Fol commented: mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmkay +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Put the text data in their own container tags. Also don't use <font> tags, they are deprecated in favor of stylesheets. Something like :

<jsp:useBean id="adminUser" class="bss.BSSUserDetailsDo" scope="session"/>
<div style='font: normal 12px verdana; color: brown;'>
<bean:message key="Bss.user.welcome"/>
<span id='firstName'><jsp:getProperty name="adminUser" property="firstName"/></span>
</div>

You were erroneously using the bean property 'firstName' to access the element of the DOM. You have got to realize that the server side constructs you are using have got nothing to do with the generated text. The user only gets the processed JSP file.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I guess he meant fear of 'God'. ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

n.aggel, maybe this would help. Follow the links and you would find some really good sites, notable among them is Topcoder which has a *lot* of practice problems under categories like 'Algorithm design', 'Software Development' and 'Software design'.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

What is the point in having multiple check boxes with the same name and value? Also as you haven't shown us your Servlet, it would be difficult for us to pin point the error. And please state your requirements a bit more clearly.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ideally there should be 'zero' Java code in your JSP file. Use JSTL's instead which help in separating the business and presentation to a greater extent. A brief tutorial here.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Peter, I think the OP wanted to upload the image from the website to the server similar to sites like YouTube where you can upload your videos.

PiusKutty, look into the Apache Commons' Fileupload module.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I wanted to become a good programmer
Becoming a good programmer is all about using the right tools at the right time. Try to learn new very high level languages like Ruby, Python etc. Every language you learn will give you a new perspective of the problem at hand.

The 'best' of programmers don't program just because they have to program, but because they want to program and can't live without it. No wonder programming is called an art.

And yes, follow the nice advice given to you on this thread. It will help you in becoming a better you. Best of luck!! :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Use the 'style' property of HTML elements.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>sample page</title>
<script type="text/javascript">
//<![CDATA[
function myLength()
{
    var str, strColor;
    var display = document.getElementById('streng');
    var element = document.getElementById('fname');
    var leng = element.value.length;
    document.getElementById('len').innerHTML = leng;
    if(leng <= 3)
    {
        str = "Weak";
        strColor= "red";
    }
    else if(leng <= 6) 
    {
        str = "Decent";
        strColor = "orange";
    }
    else
    {
        str = "Strong";
        strColor= "green";
    }
    display.style.color = strColor;
    display.innerHTML = str;
}
//]]>
</script>
</head>
<body>
<form id="frm">
<label>Enter password:</label><input type="password" id="fname" onkeyup="myLength();" /><br /><br />
<div>length of the password is: <span id="len"></span></div><br />
<div>The password is : <span id="streng" style="font-size: 20px;"></span></div>
</form>
</body>
</html>

Also read some good tutorials so that you don't have basic queries. Start here.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Something like this?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>sample page</title>
<script type="text/javascript">
//<![CDATA[
function myLength()
{
    var element = document.getElementById('fname');
    element.value = element.value.toUpperCase();
    document.getElementById('len').innerHTML = element.value.length;
}
//]]>
</script>
</head>
<body>
<form id="frm">
<label>Enter password:</label><input type="text" id="fname" onkeyup="myLength();">
<br />
<div>length of the password is: <span id="len"></span></div>
</form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I have to do a validation on date in my form.
Look into the SimpleDateFormat and GregorianCalendar classes to achieve your task.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

VLC Player, JET audio, MPStar are some options you can consider.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Just make your 'OK' button of type 'submit' and you should be good to go. Its probably the easiest way of achieving the desired task. Other options include capturing the keyboard event, checking whether a RETURN key has been pressed and handling it accordingly. This approach is best avoided unless you have some weird requirement in which you can't make the 'OK' button of type submit.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

document.getElementsByName() returns a nodeList or simply put an array. You just can't directly assign a value to an array reference. You need to do something like the one given below assuming there is only element which goes by the name of 'FromZip'. document.getElementsByName("FromZip")[0].value = 79797;

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> window.location = imageArray[ i - 1 ].href; window.location is an Object , its href property a String . Though the above one works, the correct way of writing it would be: window.location.href = imageArray[ i - 1 ].href;

itsjareds commented: window.location vs window.location.href is good :D +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You need to provide us with a 'running and short' example of your code so that we can easily test it out. Just pasting out random snippets won't do you much good.

Also take a look at the generated code for your 'in between' pages and see whether it is the same as the other ones.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

For displaying a custom dialog box, you need to use an external javascript library like YUI, Prototype.js, Mootools etc. Here is a simple example using the YUI javascript library.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

AFAIK, alert() being a blocking function will bring all the processing to a grinding halt. So, to keep the timer running when the alert() is pending for an user action seems to be a pretty difficult task.

One way you can get around this is to display an error message in a custom dialog box (made of div ) or display the error message in a span instead of doing an alert .

But as I always say, client side validation is completely at the mercy of the client and is a moot point. Server side validation is the way to go.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Glad you got rid of that book. The content it had was kind of giving us fits... ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I hope you don't say the same thing to your customers...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Your requirements are not very clear. What exactly are you trying to achieve here? Is it that if none of the values on the right list box is selected you need to select them all and if a value is selected, there should be no change?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I am almost sure that you are doing all this for display purposes. If so, then why not just use the formatting provided by the printf method.

int i = 1;
System.out.printf("%010d%n", i);
i += 10;
System.out.printf("%010d%n", i);
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

^
A sensible young man.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I thoroughly realize that, my previous post was just an observation...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> http://www.daniweb.com/forums/thread85060.html
I think this thread is turning out to be a kind of reference to all those beaten up by timing issues... ;-)

And BTW, its actually window.location.href = 'http://www.google.com' and not window.location = 'http://www.google.com' since location is an object _not_ of type String .

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Its not just about IE, Opera also works fine with the given snippet, thats almost 75% of the browser market.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> You can't control functions which belong to the owner of the
> computer that is viewing your page.
I don't think this is a question of 'controlling the functions of the owner', its rather a question which deals with the selective content which has to be served to the customer, so that the print function prints only the relevant part of the page.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Damn it, my spellchecker has got disabled again. I don't know why but any changes made to anything related to Javascript messes up with the spellchecker big time.

I guess the three options being merged into one is the cause of this.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Your code is far from being a proper XHTML document, but works in IE, since its really forgiving. A few things:

  • All the form elements should go in the form tag. Its only when they go inside the form tag, a name attribute given to them is valid, otherwise name attribute for non-form elements is deprecated.
  • The language attribute of <script> tag is deprecated. Use 'type ' instead. Something like <script type="text/javascript">.
  • Its always recommended to place your script in the header section or include it at the bottom of your page.
  • The way you are accessing the elements is completely wrong. One possible way would be to just pass the form element to the validate function and let the function pull out values from the form. Something like this: <input type="submit" value="Push" onclick="validate(this.form);" />

I would recommend you to get hold of a good tutorial (google is your friend) and start some serious reading.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

There can be a lot of reasons. Do you get any exceptions? Does the old scriptlet way of including files works?

Also make sure that you don't include a 'html' file but an 'inc' file with only the content minus the '<html>' and '<body>' tags since they are already in your original document.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yep, Tina is correct, it doesn't work for me either when using Firefox.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Its normal of Narue to disappear for sometime, reappear, post like crazy and again go in hiding. I wouldn't worry a lot if I were you. Whenever she starts posting, you would anyways come to know of her presence. :)

> so she's a family girl then
I wonder what you mean by this...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> yall can't -rep for thread-digging now
Infraction is always a viable option... ;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A very simple and crude snippet:

<select name="first" id="first" onchange="if(this.value == 'no') document.getElementById('sec').disabled=true; else document.getElementById('sec').disabled=false;">
    <option value="yes">Yes</option>
    <option value="no">No</option>
</select>
<br /><br />
<select name="sec" id="sec">
    <option value="yes">Yes</option>
    <option value="no">No</option>
</select>

I would leave to you the job of putting those bunch of statements in a separate function and changing the way the function is called as per your requirement.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The above code runs fine in IE and Opera, so it has got something to do with Firefox. I guess the only thing you can do is to let those people know of this issue and see what turns up.

Also if you want to protect your email address, you can always keep an image instead of plain text. The users who need to get in touch with you would just mail at that address. Just an option...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Don't provide the print option on the coupon page. Instead create a 'print view' button at the bottom which will take the user to a page without any frills with just the coupon. I don't know what kind of technique or server side language you are using to persist the user information, but with a bit of hacking, you should be able to easily manage it.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> And what exactly is Alice?
"Alice ML is a functional programming language based on Standard ML, extended with rich support for concurrent, distributed, and constraint programming."

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> don't use Hashtable, it's to be considered deprecated.
Plus its synchronized, making it all the more a poor choice if you don't plan on needing thread safe behavior.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Look into the Locale class. By detecting the user locale, you can pick up the corresponding information from the properties file(eg. the phone number format).