Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change search to use criteria, fix truncation
- Loading branch information
Showing
7 changed files
with
122 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/jsf/TruncatingConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.jboss.weld.examples.pastecode.jsf; | ||
|
||
import javax.faces.component.UIComponent; | ||
import javax.faces.context.FacesContext; | ||
import javax.faces.convert.Converter; | ||
|
||
public class TruncatingConverter implements Converter | ||
{ | ||
|
||
// The max length of the snippet we show | ||
private static int TRIMMED_TEXT_LEN = 100; | ||
|
||
public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) | ||
{ | ||
return arg2; | ||
} | ||
|
||
public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) | ||
{ | ||
String text = arg2.toString(); | ||
return text.length() < TRIMMED_TEXT_LEN ? text : text.substring(0, TRIMMED_TEXT_LEN) + "\n ..."; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters