当我运行JSF应用程序时,每个inputText都有一个'0',所以除非我删除'0',否则我看不到占位符。那是因为ManagedBean中的atributes是int。作为String的属性不会导致此问题,因为初始化为strName="";
我怎样才能解决问题,而不是看那些inputText的'0'值?有没有比创建那些atribues而不是int更好的解决方案,并在需要时转换为int?
XHTML
<h:inputText id="num2" label="num2" required="true" size="5" maxlength="5"
styleClass="#{component.valid ? '' : 'validation-failed'}"
value="#{sumaManagedBean.number2}" p:placeholder="Number"
requiredMessage="Enter a number">
<f:validator validatorId="numberValidator" />
</h:inputText>
<h:message for="num2" />
ManagedBean
@ManagedBean
@SessionScoped
public class SumaManagedBean implements Serializable
{
int number2;
public SumaManagedBean() {
}
//Getters and Setters
public int getNumber2() {
return number2;
}
public void setNumber2(int number2) {
this.number2 = number2;
}
}