Win a copy of Microservices in Action this week in the Web Services forum!

XiaoPeng

Greenhorn
+ Follow
since May 25, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by XiaoPeng

I have had success combining JSTL with JSF in the past prior to discovering the h:dataTable tag. In your case, you need to specify which managed-bean the list is in, i.e. ${MyListBean.list}. And make sure you have a setter and a getter for 'list' implemented in MyListBean.
11 years ago
JSF
<h:outputLink value="#{facesContext.externalContext.request.contextPath}/local_Dir/#{file.name}">
<h:outputText value="#{file.name}"/>
</h:outputLink>

#{facesContext.externalContext.request.contextPath} will get you to the root directory of your running application.
11 years ago
JSF
I have a SelectManyListbox with a custom converter for my TestCase class. I can set the SelectItem to properly accept a TestCase object with a label. I know that because the listbox displays properly. This means that the overridden Converter.getAsString method is doing its job. The problem comes when I submit the form. Normally, the setter method of a bean's array/arrayList would be called when the form is submitted. But in my case, it doesn't get invoked. Thus, my backing bean TeseCase array/ArrayList doesn't get populated. What's strange is that there are no errors or exceptions thrown either. Has anyone come across this problem before that can give me some pointers?

Thanks in advance.


Here's the Converter class:

public class TestCaseConverter implements Converter {

public Object getAsObject(FacesContext arg0, UIComponent arg1, String testCaseString)
throws ConverterException {
if (StringUtils.isEmpty(testCaseString)) {
return null;
}
System.out.println("*********************IN GETASOBJECT: "+ testCaseString + " *****************");

int descriptionIndex = testCaseString.indexOf("description");
int beginDescriptionIndex = testCaseString.indexOf("\"", descriptionIndex);
int endDescriptionIndex = testCaseString.indexOf("\"", beginDescriptionIndex+1);
String testcaseDescription = testCaseString.substring(beginDescriptionIndex+1, endDescriptionIndex);
return new TestCase(testCaseString, testcaseDescription);
}

public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2)
throws ConverterException {
return arg2.toString();
}
}

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

Here's the TestCase class:

public class TestCase {
private String description;
private String xmlForm;

public TestCase() {
description = null;
xmlForm = null;
}

public TestCase(String xml, String desc) {
xmlForm = xml;
description = desc;
}

public String getDescription() {
return description;
}

public void setDescription(String desc) {
description = desc;
}

public String getXmlForm() {
return xmlForm;
}

public void setXmlForm(String xml) {
xmlForm = xml;
}

public String toString() {
return xmlForm;
}
}

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

Here's the JSP:

<h:form id="testCaseListForm" rendered="#{InputFileParserBean.testCaseListFilled}">
<h:panelGrid columns="2">
<t:outputText value="Test Cases"/>
<h:selectManyListbox id="testCaseList" value="#{RunTestcaseBean.selectedTestcases}"
converter="TestCaseConverter"
required="true" >
<f:selectItems value="#{InputFileParserBean.testCaseList}"/>
</h:selectManyListbox>
<t:commandButton action="#{RunTestcaseBean.runTestcases}"
value="Run Test"/>
</h:panelGrid>
</h:form>
-------------------------------------------------------------------------
11 years ago
JSF