It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Java Forum

Custom Controls in JAVA

Custom Controls in JAVA

Postby achilles on Thu Apr 19, 2007 4:34 pm

hi,
I'm an aged .Net programmer and have developed like 30 websites with .Net(1.1 and 2) technologies; but since I'd like to learn different programming languages, I decided to start learning JAVA! I thought there must be some similarities; BUT THERE'S NO SIMILARITIES AT ALL.

Now, I'm using Netbeans 5.5 (+Visualweb addon) and JDK 6 rc AND I HAVE LOTS OF PROBLEMS!!

1. Inside .Net, there's a "Response.Write()" function that gives you the ability to write right into your HTML output from within the code behind. What is the equivalent in JSP?

2. In .Net there are "User controls" and "Custom Controls" to bundle some other controls(like TextBoxes, buttons, HTML and so on) into one reusable control and separate it's GUI and code logic from the main ASPX page; and I do love the first one! What is the JSP equivalent to them and is there a graphical designer to them? I saw a demo on JFrame in JAVA APPLICATIONS that's exactly what I want. but is there anything for WEB APPLICATIONS?

Thanks for all the help
achilles
 
Posts: 7
Joined: Thu Apr 19, 2007 3:38 pm
Location: Tehran-Iran

Postby ggomez on Fri Apr 20, 2007 4:34 am

1.- "out.print();" is for writing.

2.- mmmmm, you can use html to put some textboxes and buttons but java dont use any graphic stuff for web application, but you can use applets and use them to call jsp´s.
ggomez
 
Posts: 45
Joined: Tue Apr 17, 2007 3:30 am
Location: !!!!!MéXiCo¡¡¡¡¡¡

Postby mwa103 on Fri Apr 20, 2007 2:12 pm

To elaborate a little on what ggomez said. I just started using JSP for class so I'm not an expert by any definition of the word, but in my scripts so far, the "out" variable is setup by me using:
Code: Select all
PrintWriter out = res.getWriter();

Where res is the HttpServletResponse sent to the JSP page (I do this in doGet method, but I'm sure there are other methods which do the same thing).

-Mike
mwa103
100+ Club
 
Posts: 206
Joined: Mon Mar 07, 2005 10:55 pm

Postby ggomez on Fri Apr 20, 2007 6:56 pm

mmmm

yep, in servlets you can get the printwriter and named how ever you want.

but JSP established a printwriter variable named "out" so you can write anything in the web page.

is like: out.print("<h1>hi there<h1>");
ggomez
 
Posts: 45
Joined: Tue Apr 17, 2007 3:30 am
Location: !!!!!MéXiCo¡¡¡¡¡¡

Postby mwa103 on Fri Apr 20, 2007 10:27 pm

I see, guess I was wrong on that one. :oops: I guess you learn something new everyday, thanks for pointing that out to me ggomez. Now that I think about it, it was servlets I was working with. I'm doing the JSP stuff this weekend so I got a little confused. I'll be sure and remember that now. Thanks.

-Mike
mwa103
100+ Club
 
Posts: 206
Joined: Mon Mar 07, 2005 10:55 pm

Postby achilles on Sat Apr 21, 2007 7:42 pm

Thanks to you all! Thank you for being so kind not telling me:

.Net!?! Get outta here you alien!!!

just like I'm from mars or somewhere!

I tried to use out.print, and also tried to use "tld and tag handler" but I ended up in an error saying:

javax.servlet.jsp is not an object!

[import javax.servlet.jsp.tagext.*;]

i searched the Java lib and src for the class servlet and I found it inside tomcat!!! added those jar files to my references absolutely and now life's really sweat!!

everything just works fine! Now I can write into the response and develop some custom tags.

But it's really impossible for me to think of a technology like Java having no GUI designer for custom tags. Last night, one my friends (in fact, my .Net master! ) gave me a link to "myeclipse" website. they seem to have a GUI deigner for custom web controls.

Did anyone hear something like that? any experiences?

thanks again for your kind help and attention. I'm on first steps to get familiar with this technology, and I'll definitely ask some more questions, time to time...

Regards,
Achilles
achilles
 
Posts: 7
Joined: Thu Apr 19, 2007 3:38 pm
Location: Tehran-Iran

Postby ggomez on Sun Apr 22, 2007 4:36 am

i was reading about it and

"MyEclipse" looks good and it will get all the J2EE tech more easy but java doesnt accept java GUI in a web(Except for applets), it probably has a web designer with HTML forms like NETBEANS
ggomez
 
Posts: 45
Joined: Tue Apr 17, 2007 3:30 am
Location: !!!!!MéXiCo¡¡¡¡¡¡

Postby achilles on Sun Apr 22, 2007 1:42 pm

ggomez wrote:i was reading about it and

"MyEclipse" looks good and it will get all the J2EE tech more easy but java doesnt accept java GUI in a web(Except for applets), it probably has a web designer with HTML forms like NETBEANS
Hi,
Thank you Gomez. I'd just like to say Java and me are friends now! [but it's not friendly to me at all!!!]

well, I downloaded myEclipse and it's not much better than JBuilder 2007. I do love to use NetBeans 5.5 with it's visual web designer add-on. this add-on uses JSF technology to build web GUIs and connect them to a .java class as .Net's classes in CodeFile or Code behind.

But it does something else too! when sending a unicode text to a faces routine (like settext() for a label), the 2-bytes Unicode will be separated by the setText routine and will cast into 2 bytes of char, and consequently, there'll be some garbage on the browser's screen instead of the original text. [MY PAGES ARE IN FARSI/PERSIAN LANGUAGE]

I configured web.xml to use UTF-8 as jsp pages encoding, I did the same to my index.java (code behind index.jsp). my strings are well saved in jsp and java files now. but when I trace the setText() function, I see my string is taken as an Object and 2 splitted bytes passing into the function!

one thing I have in my mind to solve this! maybe writing a function in javascript to scan the strings in my labels and tables and convert them back to utf-8.
This will cost lots of performance and Server memory!

Does anyone have any other solutions?
achilles
 
Posts: 7
Joined: Thu Apr 19, 2007 3:38 pm
Location: Tehran-Iran

MMMMMM

Postby ggomez on Sun Apr 22, 2007 6:48 pm

Sorry, i´m not familiarized with your language nor that kind of issues with utf-8

but i found this example code in java about convertion unicode--utf-8

Code: Select all
try {
        // Convert from Unicode to UTF-8
        String string = "abc\u5639\u563b";
        byte[] utf8 = string.getBytes("UTF-8");
   
        // Convert from UTF-8 to Unicode
        string = new String(utf8, "UTF-8");
    } catch (UnsupportedEncodingException e) {
    }


good luck
ggomez
 
Posts: 45
Joined: Tue Apr 17, 2007 3:30 am
Location: !!!!!MéXiCo¡¡¡¡¡¡

Postby achilles on Tue Apr 24, 2007 7:39 am

Hi again!

thank you gomez. But it didn't work for me. I solved it this way:

there's a jar file named ORAI18N.JAR which is used when connecting to Oracle databases and I added it to my project's jar files; then i wrote like this:

import oracle.i18n.net.*;

.
.
.

lblCurDate.setText (URLDecoder.decode (s));

and it works just fine!!

there's e URLDecoder in java.net too, but it will not work! at least for me.

Thanks again,
Achilles
achilles
 
Posts: 7
Joined: Thu Apr 19, 2007 3:38 pm
Location: Tehran-Iran

Next

Who is online

Users browsing this forum: No registered users and 0 guests