Hi all,
I am working on making some changes to a web application as part of my
final year university project I am having some trouble with Java or
HTML (I dont know which one is causing the problem):
*-----------------------------------------------------------------------------------------------------------------*
There is class which defines a user configuration page in HTML, Ive
added some options to it, 3 radio boxes each having a particular
segment of code that willl be executed if it is selected (see further
down)
//Link Mechanism
int match = us.getMatchMode();
response += "<TR><TD colspan=\"2\"><BR><FONT size=\"+1\">Word
Recognition Mechanism</FONT></TD></TR>";
response += "<TR><TD bgcolor=\"gray\"><span
style=\"background:gray;color:white\"><INPUT TYPE=\"radio\"
NAME=\"match\" VALUE=\"" + UserSetting.CONCEPT_MATCHING + "\"" +
((match == UserSetting.CONCEPT_MATCHING) ? "CHECKED" : "") +
">Concepts</INPUT></span></TD>";
response += "<TD bgcolor=\"yellow\"><SPAN style=\"background: yellow;
color:olive;\">Use concepts from ontology to create linking
opportunities</SPAN></TD></TR>";
response += "<TR><TD bgcolor=\"gray\"><span
style=\"background:gray;color:white\"><INPUT TYPE=\"radio\"
NAME=\"match\" VALUE=\"" + UserSetting.INSTANCE_MATCHING + "\"" +
((match == UserSetting.INSTANCE_MATCHING) ? "CHECKED" : "") +
">Instances</INPUT></span></TD>";
response += "<TD bgcolor=\"yellow\"><SPAN style=\"background: yellow;
color:olive;\">Use instances from ontology</SPAN></TD></TR>";
response += "<TR><TD bgcolor=\"gray\"><span
style=\"background:gray;color:white\"><INPUT TYPE=\"radio\"
NAME=\"match\" VALUE=\"" + UserSetting.ALL_MATCHING + "\"" + ((match ==
UserSetting.ALL_MATCHING) ? "CHECKED" : "") +
">Both</INPUT></span></TD>";
response += "<TD bgcolor=\"yellow\"><SPAN style=\"background: yellow;
color:olive;\">Use both instances and concepts to create linking
opportunities</SPAN></TD></TR>";
response += "<TR><TD colspan=\"2\"><I>Note: For the fastest page
download times, use the 'Concept' method.</I></TD></TR>";
further down in this same class I update the settings, so when a button
is hit the settings are applied:
//set Linking mechanism
String[] mech = (String[]) properties.get("match");
if(mech != null && mech.length > 0) {
us.setMatchMode(Integer.valueOf(mech[0]).intValue());
System.out.println(Integer.valueOf(mech[0]).intValue());
}
The User Settings class defines all the functions it calls:
//different matching schemes
public final static int CONCEPT_MATCHING = 4;
public final static int INSTANCE_MATCHING = 5;
public final static int ALL_MATCHING = 6;
private int _match_mode = CONCEPT_MATCHING; //default state
public boolean isConcept() {
return (_match_mode == CONCEPT_MATCHING);
}
public boolean isInstance() {
return (_match_mode == INSTANCE_MATCHING);
}
public boolean isAll() {
return (_match_mode == ALL_MATCHING);
}
public void setConcept() {
_match_mode = CONCEPT_MATCHING;
}
public void setInstance(){
_match_mode = INSTANCE_MATCHING;
}
public void setAll(){
_match_mode = ALL_MATCHING;
}
public int getMatchMode(){
return _match_mode;
}
public void setMatchMode(int match){
_match_mode = match;
}
//this class method contains the segments of code to execute depending
on the configuration option selected
public void addOntology(OSUtil os, String ontology)
{
//if the concepts radio box is selected execute this segment
if (isConcept()){
execute this
}
else if (isInstance()){
execute this
}
else if (isAll()){
exeute this
}
}
*-----------------------------------------------------------------------------------------------------------------*
The Problem: No matter what radio box is selected it always executes
if (isConcept()){}, first, isAll() second and isInstance() last
irrespective of which box is selected. In orther words the radio boxes
are not causing the correct segment of code to execute.
this print:
System.out.println(Integer.valueOf(mech[0]).intValue());
reveals that the integers are correctly mapped to each radio box.
Ive been over this again and again and I just aint getting nowhere,
anyone have any suggestions?
Thanks in advance!
Roedy Green - 28 Mar 2006 20:52 GMT
>The Problem: No matter what radio box is selected it always executes
the first thing to do is validate the generated HTML. See
http://mindprod.com/jgloss/htmlvalidator.html
Then you want to get a sniffer to see what the browser is sending the
server. See http://mindprod.com/jgloss/sniffer.html
This will narrow down the source of the problem.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Martin Gregorie - 28 Mar 2006 22:00 GMT
> the first thing to do is validate the generated HTML. See
> http://mindprod.com/jgloss/htmlvalidator.html
Roedy, you might want to add HTML tidy to your reference page. Its the
definitive HTML validator and translator, originally by Dave Raggedy at
the W3 Consortium.
There are several versions including executables for Windows and Linux.
There's a Java version too. As its open source you can see how its done
as well.
All versions are free for download from http://tidy.sourceforge.net/

Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
Roedy Green - 29 Mar 2006 03:59 GMT
On Tue, 28 Mar 2006 22:00:45 +0100, Martin Gregorie
<martin@see.sig.for.address> wrote, quoted or indirectly quoted
someone who said :
>All versions are free for download from http://tidy.sourceforge.net/
it is already there as "W3C HTML Tidy"

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Light - 30 Mar 2006 15:50 GMT
I solved my problem by a complete re-write of some of the functions so
actually never passed it through the validators. Thanks for the links
though - these applications will prove useful in future.