String automatically trimed in Data Table

Hi, I get a strange behaviour of datatable in jsf. While i enter the lengthy String in datatable it get automatically trimed and remove spaces between characters. Can any one suggest me how to avoid this?
[218 byte] By [Ananth.duraia] at [2007-11-27 4:32:25]
# 1
Can you provide a small reproduceable code snippet to prove that this is caused by the datatable? I've never seen this before.
BalusCa at 2007-7-12 9:42:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hi,

<x:dataTable id="L_ALDD" first = "#{pagination.firstRowIndex}" rows="#{pagination.noOfRowsToShow}" styleClass="datatablecontentleft" var="CT4" value="#{courseAction.courseList}" border="0" summary="Admin LDCS data" rowId="#{CT4.courseId41}">

<f:verbatim><caption></caption></f:verbatim>

<x:column styleClass="cctfix">

<x:inputText id="LDCT_T4" maxlength="125" styleClass="#{CT4.courseTitleColumnColor}" value="#{CT4.courseTitle}" readonly="true" onmouseout="htt()" onmouseover="stt(event,this.value);return false" onclick="LDCTPopup(this,0,#{CT4.rowReadOnly})" forceId="true" onkeydown="tF(event,this)"/>

<h:graphicImage id="LDCT_I4" styleClass="esimg" value="#{CT4.courseTitleColumnMessageIcon}" onclick="showErrorMessage('#{CT4.courseTitleColumnMessageText}')" onmouseout="htt()" onmouseover="stt(event,'#{CT4.courseTitleColumnMessageText}','erroricon');return false" alt="" title="" />

</x:column>

<f:facet name="footer">

</f:facet>

</x:dataTable>

This is my part of coding.. while clicking the column a small popup will open with an input box.. If i enter a lengthy String as input it got automatically trimed rater to say it remove considerable amount of white spaces(not fully though).. i wonder y.. can u suggest me..

Ananth.duraia at 2007-7-12 9:42:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Which JSF implementation are you using? And have you doublechecked if those bunch of Javascripts aren't causing the trimming?
BalusCa at 2007-7-12 9:42:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Its Tomahawk bit earlier version i guess. and yes i check with javascript. i didn't trim anything. If i enter as "OraclemagazinefromOracle" means its sorted as "Oracle magazine from Oracle".. Thats my problem..
Ananth.duraia at 2007-7-12 9:42:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
hey is sorted here too.. its "oracle................. magazine...............from.........oracle" sorted to "oracle magazine from oracle"Note:i mean ...... as spaces in between the strings..
Ananth.duraia at 2007-7-12 9:42:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Ahh, this way.. Take a look in the generated HTML source of the result. Big chance that the spaces are still there ;)Try to show them in a monospaced font if you want to show the spaces anyway, like Courier New of Lucida Console.
BalusCa at 2007-7-12 9:42:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
hi,It's not rendered in html with space and i even using Courier new font.. But still no significant changes
Ananth.duraia at 2007-7-12 9:42:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

Apparently this also doesn't work with only a monospaced font. But in the HTML source I still see the spaces. And also still in the managed bean (do a system.out.println of this value to the console during the action method). To show the spaces anyway, you have to show the string as preformatted text. This can be done in 2 ways: put it inside a <pre> tag or apply white-space:pre; to the CSS of the element.

BalusCa at 2007-7-12 9:42:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

Hi,

i test with CSS.. Its going with space to managed bean. But after submition

the data table trim automatically and even the CSS helpless. This is my CSS for data table

datatable td input {

font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;

font-size: 11px;

padding: 0px 0px 0px 0px;

margin: 0px 0px 0px 0px;

text-align: left;

line-height: 1.2em;

white-space:pre;

}

Ananth.duraia at 2007-7-12 9:42:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10

The spaces are trimmed inside the input component?

Anyway, I used Sun's JSF RI implementation wile trying to reproduce the problem. As I cannot reproduce this, it is likely caused by Tomahawk somehow. Try to play with default Sun JSF RI implementation.

JSF<h:form>

<h:inputText value="#{myBean.input}" />

<h:commandButton value="submit" action="#{myBean.action}" />

</h:form>

<h:outputText value="not formatted: #{myBean.output}" />

<h:outputText value="pre formatted: #{myBean.output}" style="white-space: pre;" />

MyBeanprivate String input;

private String output;

public void action() {

System.out.println(input);

output = input;

}

public String getInput() {

return input;

}

public void setInput(String input) {

this.input = input;

}

public String getOutput() {

return output;

}

BalusCa at 2007-7-12 9:42:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11

Hi,

I feel its not working even with normal JSF.. here is my coding..

<h:form>

<h:dataTable value="#{testBean.list}" var="list" style="white-space: pre;">

<h:column>

<h:inputText value="#{testBean.input}" />

<h:commandButton value="submit" action="#{testBean.action}" />

</h:column>

<h:column >

<h:outputText value="not formatted: #{testBean.unformated}" />

</h:column>

<h:column>

<h:outputText value="pre formatted: #{testBean.formatedoutput}" style="white-space: pre;" />

</h:column>

</h:dataTable>

</h:form>

and my bean is,

public void setList(List list) {

this.list = list;

}

public List getList() {

MyBean bean = null;

List list = new ArrayList();

list.add("ananth");

return list;

}

public void setInput(String input) {

this.input = input;

}

public String getInput() {

return input;

}

public void setFormatedoutput(String formatedoutput) {

this.formatedoutput = formatedoutput;

}

public String getFormatedoutput() {

return formatedoutput;

}

public void setUnformated(String unformated) {

this.unformated = unformated;

}

public String getUnformated() {

return unformated;

}

public void action() {

System.out.println(input);

setUnformated(input);

setFormatedoutput(input);

}

i have no guess where it go wrong.. wt u thing about it..

Ananth.duraia at 2007-7-12 9:42:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 12
Hi,Any one have suggestion regarding this issue..
Ananth.duraia at 2007-7-12 9:42:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...