开发者

JSF:-Problem with the DataType and Action Listener

I am facing a problem with the dataType component and ActionListener on adding two specific component...

Code Snippet of JSF is:-

<h:outputLabel value="#{msg.org_SubscriberGroupId_1} " styleClass="intro" escape="false"/>
<h:outputLabel value="&nbsp;:&nbsp;" escape="false"/>
<h:inputText value="#{SubscriberServiceProfile.closedSubscriberGroupId1}" id="txtClosdGrup1" styleClass="textBox" label="#{msg.org_SubscriberGroupId_1}" />                                                     

<h:outputLabel value="#{msg.org_expiryDate_1}" styleClass="intro" escape="false"/>
<h:outputLabel value="&nbsp;:&nbsp;" escape="false"/>
<rich:calendar id="expiryDate1" value="#{SubscriberServiceProfile.dtExpiryDate1}" styleClass="textBox" datePattern="dd-MMM-yyyy" required="false" label="#{msg.org_expiryDate_1}" />

The code repeats 5 times...with different ids...and different indexes...

My backing Bean code is:-

public class ServiceProfile
{

private String closedubscriberGroupId1="0";
private String closedSubscriberGroupId2="0";
private String closedSubscriberGroupId3="0";
private String closedSubscriberGroupId4="0";
private String closedSubscriberGroupId5="0";
private Date dtExpiryDate1;
private Date dtExpiryDate2;
private Date dtExpiryDate3;
private Date dtExpiryDate4;
private Date dtExpiryDate5;

//respective getters and setters

public void create(ActionListener act)
{
//action listener code
}

}

The problem is with the dataType of either ClosedSubscriberGroup or Expiry date.. User will enter integer value in closedSubscriberGroup Id 开发者_JS百科input field.

But the problem is that my actionListener is not getting fired until and unless I specify the values in all the 5 text boxes of closedSubscriberGroupId..No validation is there in JSF.Still it is not allowing me to submit the form and call actionListener.

What can be the possible problem..????..Is it the DataType??? or any other problem??... Please guide me....


From your comment , it seems that you want to set the values you enter in the <h:inputText> and <rich:calendar> to its backing beans and invoke the bean method immediately whenever onchange event on the <h:inputText> and <rich:calendar> happens

You could use the a4j:support :

<rich:calendar value="#{bean.date}" styleClass="textBox" datePattern="dd-MMM-yyyy" required="false">
    <a4j:support event="onchanged" action="#{bean.onChangeDate}" ajaxSingle="true"/>
</rich:calendar>

<h:inputText value="#{bean.aString}"  styleClass="textBox">
    <a4j:support event="onchange" action="#{bean.onChangeText}"  ajaxSingle="true" />
</h:inputText> 

It means that whenever onchange events happen on <h:inputText> and <rich:calendar> , an Ajax request will be fired to invoke the method specified by the action attribute. The ajaxSingle attribute is important here as it will set the values you entered in the controls immediately to its backing bean before the action are invoked.

Note that for the rich:calendar , the onchange event is onchanged instead of onchange

Reference:

  • a4j:support Demo
  • http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/a4j_support.html
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜