• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

onblur is not called in inputText ...please help me if any body had same situation or aware of issue

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my msform.xhtml file has below code:

<t:dataTable value="#{msrFormBB.meterEquipmentInfo}" var="dataItem" cellpadding="0" cellspacing="0" rows="10" styleClass="XcomReadsTable" style="width: 100%;" rowClasses=",Flop">


<h:inputText size="10" maxlength="9" value="#{dataItem.serialNumber}" onblur="getReOrderNumber()" />




getReOrderNumbers() is call defined in backing bean but i ma not sure why this function was not called when i entered and moved from above inputText field.

If you need any more details from my side, please let me know
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The onblur attribute sets the JavaScript code to execute when this element loses focus. It can not set the value in the backing bean.

What exactly you are trying to do ?Could you please provide some more information ?
 
Mallika gowd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply Srini.


well, i have a requirement where user enter value in inputText and when looses focus from it it should call a method(server side call) where i inluded code to gerente list of records from xml file based on input entered entered by the user in inputText field.

yes as i have limited knowledge in JSF, please let me know what are all the options i have to call method in backing bean from JSF.

 
Saloon Keeper
Posts: 28398
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mallika gowd wrote:Thanks for your reply Srini.


well, i have a requirement where user enter value in inputText and when looses focus from it it should call a method(server side call) where i inluded code to gerente list of records from xml file based on input entered entered by the user in inputText field.

yes as i have limited knowledge in JSF, please let me know what are all the options i have to call method in backing bean from JSF.



onblur is a client-side event. To call the server, you're either going to have to make the client-side javascript force a form submit or you're going to have to send an AJAX request.
 
Mallika gowd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim


could you please give example in AJAX to call method from JSF to backing bean method.


thanks in advance.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just try with valueChangeListner in inputText. it may work out.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in the first case directly associating with a variable

<a4j:region rendered="true">
<h:inputText size="15" id="idname"
value="#{ddd.variblename}" rendered="true"
maxlength="10">
<a4j:support event="onkeyup" ajaxSingle="true">
</a4j:support>
</h:inputText>
</a4j:region>

or

<a4j:support event="onblur"
actionListener="#{xxxxx.methodToBecalled}"
reRender="specify the ids seperated by commas of those components once the response is send back">

</a4j:support>
 
Mallika gowd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vishwanath,


I tried to implement AJAX but may be some thing wrong in my implementation. please let me know anything wrong i am doing here below.

Backing bean method never called from xhtml.

msrform.xhtml -->

<t:dataTable value="#{msrFormBB.meterEquipmentInfo}" var="dataItem" cellpadding="0" cellspacing="0" rows="10" styleClass="XcomReadsTable" style="width: 100%;" rowClasses=",Flop">


<h:inputText id="myInput" size="10" maxlength="9" value="#{dataItem.serialNumber}"/>

<a4j:support event="onblur" actionListener="#{msrFormBB.reOrderNumbers}" reRender="myInput"> </a4j:support>

</t:dataTable >




backing bean --> msrFormBB-->


Below is the method we are calling from JSF.


public void getReOrderNumbers() {
System.out.println("first step");
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringComments(true);
System.out.println("first step");

factory.setIgnoringElementContentWhitespace(true);
factory.setValidating(true);

DocumentBuilder builder = factory.newDocumentBuilder();
System.out.println("second step");

Document doc = builder.parse(new InputSource("c://projects/ms/WebContent/xmlSuppliesByProductCode.xml"));

System.out.println("third step");

Element root = doc.getDocumentElement();

Element movieElement = (Element) root.getFirstChild();
System.out.println("fourth step");
String serialProdCode="3G3";
System.out.println("serial prod code:"+serialProdCode);

while (movieElement != null) {

ReorderNumGen m = getReOrder(movieElement);
if ((m.productCode).equalsIgnoreCase(serialProdCode))
{
meterReOrderNumGen.add(m);
System.out.println("meter ReOrder Number Generation");
}
String msg = m.productCode;
msg += "," + m.reOrderNumber;
msg += "," + m.desc;

System.out.println(msg);
movieElement = (Element) movieElement.getNextSibling();
}

}catch(Exception e){System.out.println("ABCD"); }



}
 
Viswanath Tg
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Your implementation
<h:inputText id="myInput" size="10" maxlength="9" value="#{dataItem.serialNumber}"/>

<a4j:support event="onblur" actionListener="#{msrFormBB.reOrderNumbers}" reRender="myInput"> </a4j:support>

Required is - Try this

<h:inputText id="myInput" size="10" maxlength="9" value="#{dataItem.serialNumber}">

<a4j:support event="onblur" actionListener="#{msrFormBB.reOrderNumbers}" reRender="myInput"> </a4j:support>
</h:inputText>
 
Mallika gowd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Viswanath.

yes, I even tried the below option and still i am not able to call the method in BB.

Note: I am using DataTable..is that causing any problem...please see my previous post for code.


thanks for your help.


hey...you from Adoni?
 
Viswanath Tg
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

When on blur event is fired what is displaying in logs....




<a4j:region>
<a4j:form>
<rich:dataTable id="myList" rows="15"
value="#{xxx.myList}" var="abc"
width="100%" >

<rich:column>
<f:facet name="header">
<h:outputLabel
value="#{message['sss.bbbb']}" />
</f:facet>

<a4j:region>
<h:inputText value="#{xxxx.op}"
style="width:70px;text-align:right;"
maxlength="9" id="opid">
<a4j:support event="onblur"
action="#{varible as declared in facesConfig.methodnameofBakingBean}"
reRender="particularId">
</a4j:support>

</h:inputText>
</a4j:region>
</rich:column>
</rich:dataTable>
</a4j:form>
</a4j:region>


Replace action listner with action....

One more thing for debugging use a command button and on click of that button check weather the event is firing or not

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mallika,

Instead of actionListener try using an action which is bound to a backing bean method.

<a4j:support event="onblur" action="#{msrFormBB.reOrderNumbers}" reRender="myInput"> </a4j:support>

reOrderNumbers method signature should not have any ActionEvent object.
 
Mallika gowd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used action instead actionLister even though the BB method is not getting called.

I am posting my code below.

<t:dataTable value="#{msrFormBB.meterEquipmentInfo}" var="dataItem" cellpadding="0" cellspacing="0" rows="10" styleClass="XcomEqTable" style="width: 100%;" rowClasses=",Flop">

<t:column styleClass="ColPos0">
<f:facet name="header">
<h:outputText value="Serial Number*"></h:outputText>
</f:facet>


<h:inputText id="myInput" size="15" maxlength="9" value="#{dataItem.serialNumber}">
<a4j:support event="onblur" action="#{msrFormBB.reOrderDetails}" reRender="myInput"> </a4j:support>
</h:inputText>

</t:dataTable>

please help me on this.
 
Abhishk Gupta
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mallika,
Please post the method reOrderDetails too.
 
Mallika gowd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for quick replay abhishek.

I would like to give brief about my code here....

I have two section in my UI form..that is equipment section and supplies section.
and i defined two different dataTables for above two section.
So when user enters all equipments in dataTable #1 section values should populate supplies order details based on the equipments entered by the user

equipment section jsf code:

<t:dataTable value="#{msrFormBB.meterEquipmentInfo}" var="dataItem" cellpadding="0" cellspacing="0" rows="10" styleClass="XcomEqTable" style="width: 100%;" rowClasses=",Flop">

<t:column styleClass="ColPos0">
<f:facet name="header">
<hutputText value="Serial Number*"></hutputText>
</f:facet>


<h:inputText id="myInput" size="15" maxlength="9" value="#{dataItem.serialNumber}">
<a4j:support event="onblur" action="#{msrFormBB.reOrderDetails}" reRender="myInput"> </a4j:support>
</h:inputText>

</t:dataTable>



Supplies Section JSF code:


<t:dataTable value="#{msrFormBB.meterSuppliesInfo}" var="dataItem" cellpadding="0" cellspacing="0" rows="30" styleClass="XcomSuppTable" style="width: 100%;" rowClasses=",Flop">

<t:column styleClass="ColPos0">

<f:facet name="header">
<h:outputText value="Supply Reorder Number*"></h:outputText>
</f:facet>

<h:selectOneMenu size="45" value="#{dataItem.suppReOrderNumber}" >
<f:selectItem itemValue="" itemLabel="Please Select"/>
<f:selectItems value="#{msrFormBB.sortOptions}" />

</h:selectOneMenu>


</t:column>
</t:dataTable>

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

Now little expalination about Backing Bean msrFormBB

there i have two lists defined to popupate and insert data in to the database they are 1)msrFormBB.meterEquipmentInfo 2) msrFormBB.meterSuppliesInfo


And about method msrFormBB.reOrderDetails

above method will get the reorder numbers based the serail numbers entered in equipment section will add them to sortoptions list which i have populated in supplies section ..(code in JSF <f:selectItems value="#{msrFormBB.sortOptions}")


So finally when user enters serial numbers in equipment section....supplies sections supplyreordernumber should populate in dropdown.


if you need more details let me know.thanks in advance for your help.


 
Mallika gowd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry i forgot to post my reorderdetails code.


here we go
------------
/*
* getting Re order numbers based on the serial numbers entered by the user
* in the equipment section and adding them to the sort options list.
*/
public void reOrderDetails() {
List<MeterSuppReorder> updates = new Vector<MeterSuppReorder>();
List<MeterSuppReorder> prodList = new Vector<MeterSuppReorder>();

StringBuffer inProdList = new StringBuffer("");
sortOptions = new Vector<SelectItem>();
meterReOrderNums = new Vector<MeterSuppReorder>();

if ((meterEquipmentInfo == null) || (meterEquipmentInfo.size() == 0)) {
meterEquipmentInfo = new Vector<MeterSuppReorder>();
}

if ((meterSuppliesInfo == null) || (meterSuppliesInfo.size() == 0)) {
meterSuppliesInfo = new Vector<MeterSuppReorder>();
}

try {

int count = 0;
for (int i = 0; i < meterEquipmentInfo.size(); i++) {
MeterSuppReorder inv = meterEquipmentInfo.get(i);

if (!MeterSuppReorderUtil.isEmptyString(inv.getSerialNumber())) {
count++;
}
}
String[] params = new String[count];

// ArrayList<String> params = new ArrayList<String>();
int m = 0;
for (int i = 0; i < meterEquipmentInfo.size(); i++) {
MeterSuppReorder inv = meterEquipmentInfo.get(i);

if (!MeterSuppReorderUtil.isEmptyString(inv.getSerialNumber())) {
String prodCode = inv.getSerialNumber().substring(0, 3)
.toUpperCase();
params[m] = prodCode;
m++;
} else {
updates.add(inv);
}

}
if (updates.size() == meterEquipmentInfo.size()) {
this.noValuesEnteredMsg = "emptySerialReadMsg";

}

try {

// Call to DB to get re order numbers

if (params.length != 0) {
meterReOrderNums = MeterSuppReorderDAO.getRONumbers(params);
}
System.out.println("successfully calling the re order details method");
// Adding re order number list to sortOptions
if ((meterReOrderNums.size() != 0)
&& (meterReOrderNums != null)) {
for (int i = 0; i < meterReOrderNums.size(); i++) {
MeterSuppReorder rec = meterReOrderNums.get(i);
sortOptions.add(new SelectItem(rec.getReOrderNumber(),
rec.getReOrderNumber() + " - "
+ rec.getDescription()));
}
} else {
if (meterSuppliesInfo.size() != 0) {
this.noReorderNumMsg = "noReorderNumMsg";
}
}
} catch (SQLException e) {
log.debug("error occured while getting the reorder number list from DB");
e.printStackTrace();

}
 
Abhishk Gupta
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Frankly speaking I could not find anything wrong with the code. Moreover there is no validation in the page(atleast in the code shared).
But as we know the unpredictable behavior of ajax4jsf, try this:

<a4j:support event="onblur" action="#{msrFormBB.reOrderDetails}" reRender="myInput" immediate="true "></a4j:support>
instead of
<a4j:support event="onblur" action="#{msrFormBB.reOrderDetails}" reRender="myInput"></a4j:support>.

Please note, this is not a solution but just a workaround.
To check what's happening here, put it in your jsp
<a4j:outputPanel ajaxRendered="true">
<h:messages />
</a4j:outputPanel>

cheers
 
Mallika gowd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I did not understand the below part.

Please note, this is not a solution but just a workaround.
To check what's happening here, put it in your jsp
<a4jutputPanel ajaxRendered="true">
<h:messages />
</a4jutputPanel>



could you please give more details where to include above code to track any errors?
 
Abhishk Gupta
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
did immmediate=true didn't work
anyways,

reloads the page and display error messages, if any
 
Mallika gowd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did try immediate="true" but it didnt work...


any further help will be highly appreciated.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic