well-formed character problem
pete007 Feb 12, 2008 10:38 AMHi, I am getting the following message in different use-cases:
Error Parsing /router.xhtml: Error Traced[line: 22] The content of elements must consist of well-formed character data or markup.
First one is, when I use german Umlaute like ä.
How do I write this Characters correctly into the xhtml-document?
the other one is maybe a thinking error by myself. I am trying to iterate over a String-Array and to print all elements to screen, in this case in a html-drop-down-select-box.
At first, I had this code, which worked, but it was very slow, because it called router.getEndNodes() for every element.
<select name="end" rendered="#{router.endNodes!=null}"> <c:forEach var="w" items="${router.endNodes}"> <option value="${w}">${w}</option> </c:forEach> </select>
I changed the getEndNodes-Method to cache the Strings and not load them from the database at every method call.
@Transient public String[] getEndpointNames() { if(namearray==null) { namearray = loadEndNodes(); } return namearray; } @Transient public String[] loadEndpointNames() { ArrayList<String> nl = (ArrayList<String>) entityManager.createQuery("select name from Endpoint order by name").getResultList(); String[] na = new String[nl.size()]; int counter = 0; for(String name: nl) { na[counter++] = name; } return na; }
But this is still very slow (about 5 seconds for 200 short string elements).
So I thought about caching the String[] in the html/jsp/xml-page itself by assigning it to a temporary variable:
<% String[] endNodes = ${router.endNodes}; %> <select name="end" rendered="#{endNodes!=null}"> <c:forEach var="w" items="${endNodes}"> <option value="${w}">${w}</option> </c:forEach> </select>
And then I get again the above error message from the parser.
Do I have to wrap the statement, some characters, did I type it wrong or is it not possible to do such an assignment at all?
By the way, Is there no predefined tag for select-boxes?
If someone has a better solution for the drop-down-box, please post it. I'm not bound to any datatypes, it's only strings defined in a database.
Thanks in advance, Peter