Tak Ng

Greenhorn
+ Follow
since Jun 05, 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 Tak Ng

Exadel Studio Pro is a good candidate. It offers graphical preview and code highlight. You can download a trial from www.exadel.com

By August, this Eclipse plugin should become open source.

Note: I'd recommend you to understand well JSF lifecycle; otherwise, you could get into many "unexplainable" issues.
14 years ago
JSF
These are the steps taken by JSF life cycle:
1) if the drop down menu changes, selectedOptionChanged will get called.
2) if the value of selectedOption is "other", the flag activateOtherInput is activated; otherwise, it is off.
3) the other input textfield appears depending on the flag activateOtherInput.

The disadvantage of this method is an additional round trip to the server, but you avoid writing your own javascript.

class ExampleForm{
private String selectedOption;
private String otherInput;
private boolean activateOtherInput;

public void selectedOptionChanged(ValueChangeEvent event){
if(selectedOption.equals("other") //Or whatever value you might have
activateOtherInput = true;
else
activateOtherInput = false;
FacesContext context = FacesContext.getCurrentInstance();
selectedOption = (String)event.getNewValue();
context.renderResponse();
}
...
//Rest of code
}

example.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>

<html><head></head><body>
<h:selectOneMenu value="#{exampleForm.selectedOption}" onchange="submit();"
valueChangeListener="#{exampleForm.selectedOptionChanged}">
<f:selectItem value="PC" label="PC"/>
<f:selectItem value="Mac" label="Mac"/>
<f:selectItem value="other" label="Other"/>
</h:selectOneMenu>
<h:inputText value="#{exampleForm.otherInput}" rendered="#{exampleForm.activateOtherInput}"></f:inputText>
</body>
</html>
14 years ago
JSF
The checked property sets or returns whether or not a radio button is checked.
It does not give you the value of your radio button.
14 years ago
JSF
You might use a workaround. Have the drop down list activates another textfield only when the user selects "Other" option. Tell me if you need a working example on how to do it.
14 years ago
JSF
Can you post the error message, the jsp code and the java class you are using?
14 years ago
JSF
It depends on the validator you are using on this date field. Please follow these steps:

1) First, add a message bundle to your jsp page in the <head> section. Below is an example:
<f:loadBundle basename="com.xyz.messages" var="msgs"/>

2) You need to create for the above example a file called "messages.properties" in the package com/xyz (change it for the package of your application).

3) On your faces-config.xml, add
<faces-config>
...
<application>
<message-bundle>com.xyz.messages</message-bundle>
</application>
...
</faces-config>

4) Inside "messages.properties", replace the resource ID of the validator you are using with a custom message you want to set. For example, if you use the standard length validator that comes with jsf, you can overwrite the custom message of maximum length with the following line:

javax.faces.validator.LengthValidator.MAXIMUM=You have passed the maximum value allowed for this field.

Since I don't know which validator your are using, you have to look at the API documentation of your validator the corresponding Resource ID (javax.faces.validator.LengthValidator.MAXIMUM is the Resource ID of the previous example).

For reference, you can get a copy of Laxxuss' "Core JavaServer Faces". It is a good book on JSF.

Hope it helps.
14 years ago
JSF
Can you post the code of your class?
14 years ago
JSF
I don't really get you. How is that you get an error when you try to post your code?
14 years ago
JSF
Do you have any validation in your listbox? It seems that the form is sending back to the server some invalid data and the validation phrase is catching it. It will help if you post the code of your jsp page.
14 years ago
JSF
Try this on your jsp page:

Rendered=�#{UserBean.source}�

As I know, bean property name should not start with a capital letter. Even if you have accessors called getSource and setSource, reference to this property in the jsp page should be #{UserBean.source} This is a Java convention.
14 years ago
JSF
On the line
<h:commandButton action="tableData.saveEditedRow" value="save">

you must surround "tableData.saveEditedRow" with #{} so it becomes

<h:commandButton action="#{tableData.saveEditedRow}" value="save">
14 years ago
JSF
Can you post the JSP/JSF and Java code you are using to display the message?
14 years ago
JSF
Well. You might ask the users whether they need or not results of up to 10k records. I think that most ordinary user will try to filter out records and reduce the number of records returned.

10k records will certainly consume memory and slow down the page. I think that for most people, 200 records will be fine. You might tell the end users that 200 records are being displayed but there are 10k records in the database.

Hope it helps.
14 years ago
JSF
If you have a property in a backing bean associated to the radio button, you can set a default value in the backing bean and when the page loads, it will be selected by default.
14 years ago
JSF
The attribute immediate set to "true" is commonly used when you want to cancel a form. In any other case, you should not activate immediate as it skips validation.
14 years ago
JSF