Solved

How JSP transform Struts tags using DOM ?

Posted on 2006-07-13
5
408 Views
Last Modified: 2013-11-19
When I use DOM in javascript to construct a Struts tag, per example:

var new_obj = document.createElement("input")
new_obj.type='text'                    
new_obj.name='formLigacoesMultiplasCamadaIFrame'
new_obj.property='nomeLigacao'
new_obj.styleClass='SubFormTextbox'
new_obj.maxlength='10'  
new_obj.disabled='false'
parent_obj.appendChild(new_obj)    

JSP transform this in the following tag:

<input disabled property=”nomeLigacao” styleClass=”SubFormTextbox” maxlength=”10”>

But when i construct the tag in HTML:

<html:text name="formLigacoesMultiplasCamadaIFrame" property="nomeLigacao" styleClass="SubFormTextbox" maxlength="10" disabled="false"/>

JSP transform this in the following tag:

<input class=SubFormTextbox disabled maxlength=10 value=teste name=nomeLigacao>

Note: in the last tag, “teste” is the value that I gave to “nomeLigacao” in my Stuts action

Could anyone tell why this happens? I need to obtain the same result through DOM or through HTML.

Thanks
0
Comment
Question by:NUNOPALMA
  • 3
  • 2
5 Comments
 
LVL 19

Expert Comment

by:dakyd
ID: 17101419
I'm not sure I understood your question, but if you're asking how to set the value of an input using the DOM, then you'd do it like this:

var new_obj = document.createElement("input");
new_obj.type='text';
new_obj.name='formLigacoesMultiplasCamadaIFrame';
new_obj.property='nomeLigacao';
new_obj.styleClass='SubFormTextbox';
new_obj.maxlength='10';
new_obj.disabled='false';
new_obj.value = 'teste';
parent_obj.appendChild(new_obj);

Hope that helps.
0
 

Author Comment

by:NUNOPALMA
ID: 17101620
No, it isn't exactly that. I want to set the value and the other attributes of an input using my Struts action and my CSS within DOM

0
 
LVL 19

Expert Comment

by:dakyd
ID: 17101805
Wait, so you want Struts to interact with the DOM?  I don't really use Struts, but from my understanding, that's done on the server-side, isn't it?  The DOM is on the client-side, so you can't make the two interact very easily.  What exactly are you trying to do?  If all you want is to modify the HTML on a given page, the DOM should be enough.  I guess I'm just not following what the desired result is, so I'm not sure what to suggest.

Also, I just noticed that I was setting the CSS class wrong.  Instead of this:
  new_obj.styleClass='SubFormTextbox';
you should use:
  new_obj.className='SubFormTextbox';
0
 

Author Comment

by:NUNOPALMA
ID: 17108485
I already solved my problem. I used innerHTML instead of DOM to construct the Struts tags. It works as i wanted: it uses the action that i defined.

Thanks dakyd
0
 
LVL 19

Accepted Solution

by:
dakyd earned 500 total points
ID: 17108768
Glad to hear it's working the way you want, although anything you can do with innerHTML should be possible with the DOM as well.  *shrug* So long as it works.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to count occurrences of each item in an array.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now