?
Solved

How JSP transform Struts tags using DOM ?

Posted on 2006-07-13
5
Medium Priority
?
414 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 1000 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

777 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