Solved

How JSP transform Struts tags using DOM ?

Posted on 2006-07-13
5
412 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The viewer will learn how to count occurrences of each item in an array.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

730 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