?
Solved

Changing bean message without reloading page

Posted on 2005-02-25
8
Medium Priority
?
309 Views
Last Modified: 2010-04-01
hi!

I am trying to change bean message without reloading page upon button click event. Is there any way of doing it?
++++++++++
<table align="center" width="25%" cellspacing="0" cellpadding="0">
      <tr>
       <th span class="entrycolor"><bean:message  key="firstentry" /></span></th>
      </tr>
</table>
++++++++++++
Or, is there any way of changing font and color of  html:text value just like bean message?
thanks,
0
Comment
Question by:dkim18
[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
8 Comments
 
LVL 29

Accepted Solution

by:
bloodredsun earned 200 total points
ID: 13407868
To both questions:

You could do it via some JavaScript and the onChange event handler.

Remember, the tags are compiled to HTML so you can write JavaScript to alter this, the same way you could change any code.
0
 
LVL 7

Assisted Solution

by:lhankins
lhankins earned 200 total points
ID: 13411543
Add an id entry to your span and an onclick handler, then you can use javascript to find the dom element and change the CSS class, for example:

---------------------------------------------------------------------------------------------------------------------------------------------
<!---HTML -->
<table align="center" width="25%" cellspacing="0" cellpadding="0">
     <tr>
      <th> <span id="firstEntrySpan" onclick="handleSpanClick()" class="entrycolor"><bean:message  key="firstentry" /></span></th>
     </tr>
</table>


<!-- JS Function to swap CSS class onclick -->
<script type="text/javascript">
function handleSpanClick()
{
   var span = document.getElementById("firstEntrySpan");

   if (span.className == "entrycolor")
       span.className = = "highlightedcolor";
   else
      span.className = "entrycolor";
}
</script>

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Of course you'll want to define a new css class as well called "highlightedcolor", something like :

<style type="text/css">

*.highlightedcolor
{
   background-color: yellow;
   color:black;
}
</style>
0
 
LVL 7

Expert Comment

by:lhankins
ID: 13411566
here's a fully functional example, cut-n-paste locally and play with it :

----------------------------



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>

   <title>test</title>

   <style type="text/css">
   *.entrycolor {
      background-color: white;
      color: black;
   }

   *.highlightedcolor {
      background-color: yellow ;
      color: black;
   }

   </style>

   <script type="text/javascript">
   function handleSpanClick(anElement)
   {
      if (anElement.className == "entrycolor")
      {
         anElement.className = "highlightedcolor";
      }
      else
      {
         anElement.className = "entrycolor";
      }
   }
   </script>


</head>

<body>

<div class="outer">
   <div class="floatRight">
      <table>
         <tr>
            <td><span class="entrycolor" onclick="javascript:handleSpanClick(this);">entry 1</span></td>
         </tr>
         <tr>
            <td><span class="entrycolor" onclick="javascript:handleSpanClick(this);">entry 2</span></td>
         </tr>
         <tr>
            <td><span class="entrycolor" onclick="javascript:handleSpanClick(this);">entry 3</span></td>
         </tr>
      </table>
   </div>
</div>
</body>

</html>
0
 
LVL 7

Expert Comment

by:lhankins
ID: 13411570
(ignore the div stuff there, that's left over from a previous testbed...)
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13622467
split between lhankins  and bloodredsun
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 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