• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to add "...." after a sentence using Ajax display tag

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
need a urgent help on Ajax.
I am using Ajax,Spring,Struts for my project.
I need help in two place :--

1. I am displaying a link which contains first 20 character of a comment and this first 20 character will end with "...." to show that this link contains more information.
After clicking on that link user can view full comment.
I want to append "...." after that 20 character using Ajax display tag.

2.I have an add comment page which will add some comment to database after clicking a save button. Maximum comment size will be 4000 character . But If I enter more then 2000 character then my form is not submiting and it is not showing any error.It simply dies there no action is performed there.

Please help in solving this problem.

Below is the code of my addComment.jsp.

<%@ include file="/common/taglibs.jsp"%>


<script language="javascript" type="text/javascript">

focusOnTextArea=function(){
document.getElementById('commentDesc').focus();

}
// --------------------------------------------------------------
// Save functions
// --------------------------------------------------------------
validateSave = function()
{
var valid = true;
var module = $F('module');
var commentDesc= $F('commentDesc');

if (module == "0")
{
alert("Please Select module.");
valid = false;
return valid;
}else {
focusOnTextArea();
}
if (commentDesc == "")
{
alert("Please Enter Comment.");
document.getElementById('commentDesc').focus();
return false;
}
if(commentDesc.length >= 4000){
alert("Comment should be less than 4000 characters.");
document.getElementById('commentDesc').focus();
valid = false;
}
return valid;
};

preSave = function()
{
var keepGoing = validateSave();
alert("Return Value===" +keepGoing);
if (keepGoing)
{
var method = $('method');
method.value='save';
var params = $('ajax');
params.value = Form.serialize('commentForm');
}
return keepGoing;
};

postSave = function()
{
var params = $('ajax');
params.value="";
};

errorSave = function()
{
alert("error");
};

// --------------------------------------------------------------
// Reset functions
// --------------------------------------------------------------
preReset = function()
{
var method = $('method');
method.value='reset';

};

postReset = function()
{

};

errorReset = function()
{
};
</script>



<div id="ajaxCommentForm">
<table class="componentContent">
<html:form styleId="commentForm" method="POST" action="/addCommentAction">

<html:hidden styleId="method" property="method"/>
<input id="ajax" type="hidden" value=""/>

<c:if test='${not empty commentForm.message}'>
<script>setTimeout("Effect.DropOut('savedMsg')", 2500);</script>
<div id="savedMsg" class="successMsg">${commentForm.message}</div>
</c:if>

<tr>
<td class="label">Module:</td>
<td>
<html:select styleId="module" name="commentForm" property="moduleId" onchange="focusOnTextArea()">
<html ption value="0">--Please Select--</html ption>
<c:forEach var="module" items="${dataList}">
<html ption value="${module.moduleId}">
<c ut value="${module.moduleName}"/>
</html ption>
</c:forEach>
</html:select>
</td>

</tr>

<tr>
<td class="label" valign="top">Comment:</td>
<td colspan="3">
<html:textarea property="commentDesc" rows="6" cols="50" />
</td>
</tr>
<tr>
<td colspan="3" align="center">
<table class="componentContent">
<tr>
<td align="right"><input id="saveButton" type="button" value="Save" class="button"/></td>
<td align="left"><input id="resetButton" type="button" value="Reset" class="button"/></td>
</tr>
</table>
</td>
</tr>
</html:form>
</table>
</div>
<ajax:htmlContent
baseUrl="addCommentAction.do"
source="resetButton"
target="ajaxCommentForm"
parameters="method={method}"
preFunction="preReset"
postFunction="postReset"
errorFunction="errorReset"/>

<ajax:htmlContent
baseUrl="addCommentAction.do"
source="saveButton"
target="ajaxCommentForm"
parameters="form={ajax},method={method},commentDesc={commentDesc}"
preFunction="preSave"
postFunction="postSave"
errorFunction="errorSave"/>

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read this to see why posting phrases such as:

need a urgent help on Ajax.



is likely to get your post ignored.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic