-
1. Re: Create Search
lvdberg Sep 21, 2011 2:09 PM (in response to pradeep6336)Hi,
the documentation, the examples in the distro and the available book contain a lot of information. It will take a long time until somebody helps you at this forum, because you really should try there first.
Leo
-
2. Re: Create Search
pradeep6336 Sep 22, 2011 8:19 AM (in response to pradeep6336)any links please leo
i am writing some code but there is a errors.
here is my code
-------------------------------------------------@DataModel private List<MobeeTopupTr> topUpTrList; @DataModelSelection("topUpTrList") private MobeeTopupTr selectedTr; @Begin(join = true) public String searchTopupTr(){ topUpTrList = new ArrayList<MobeeTopupTr>(); String instCode = (String) Contexts.getSessionContext().get(MobeeSessions.INST_ID.getSessionName()); searchKeyword = searchKeyword.trim(); if(searchKeyword != null && searchKeyword.equals(" ")){ List<MobeeTopupTr> trList = (new MobeeTopupController()).retrieveAllTr(searchKeyword, instCode); topUpTrList.addAll(trList); } return null; } @Factory("topUpTrList") public List<MobeeTopupTr> retrieveAllTr(String msisdn, String instCode){ return topUpTrList = airtimeDatabase.createQuery("from mobeeTopUpTr tr where tr.msisdn=:MSISDN and tr.instId=:INSTCODE") .setParameter("MSISDN", msisdn).setParameter("INSTCODE", instCode).getResultList(); }
--------------------------
my xhtml page<h:inputText id="searchValue" required="true" value="#{mobeeTopupController.searchKeyword}" style=" width : 195px;"> </h:inputText> <a:commandButton id="search" eventsQueue="searchAgent" action="#{mobeeTopupController.searchTopupTr}" status="waitstatus" value="#{messages.buttonsearch}" styleClass="defaultButton"> </a:commandButton> <h:outputText value="No Topup Users exists" rendered="#{empty topUpTrList}" /> <rich:datascroller align="center" for="topupTr" id="ds" renderIfSinglePage="false"></rich:datascroller> <rich:spacer width="5" height="10"></rich:spacer> <rich:dataTable id="topupTr" var="topup" width="100%" value="#{topUpTrList}" rowKeyVar="row" rendered="#{not empty topUpTrList}" rows="5" headerClass="headerGreen1" rowClasses="odd-row, even-row"> <rich:column align="center" colspan="1"> <f:facet name="header">MSISDN</f:facet> <h:outputText value="#{topup.msisdn}" /> </rich:column> <rich:column align="center"> <f:facet name="header">Client Ref Num</f:facet> <h:outputText value="#{topup.clientRefNo}" /> </rich:column> <rich:column align="center"> <f:facet name="header">Country</f:facet> <h:outputText value="#{topup.country}" /> </rich:column> <rich:column align="center"> <f:facet name="header">Status</f:facet> <h:outputText value="#{topup.statusCode}" /> </rich:column> </rich:dataTable>
I receive this error
--------------------
Caused by: java.lang.IllegalArgumentException: Could not invoke method by reflection: MobeeTopupController$$javassistseam9.retrieveAllTr(java.lang.String, java.lang.String) with parameters: (org.jboss.seam.Component) on: com.manam.mobee.airtime.MobeeTopupController$$javassistseam9Caused by: java.lang.IllegalArgumentException: wrong number of arguments
any help could be thanks
-
3. Re: Create Search
lvdberg Sep 22, 2011 8:31 AM (in response to pradeep6336)Hi,
The errormessage is very clear:
wrong number of arguments and
Could not invoke method by reflection: MobeeTopupController$$javassistseam9.retrieveAllTr(java.lang.String, java.lang.String)When you look at the code, the retrieveAllTr method has two Strings in its method, but in your page you are calling topUpTrList without arguments.
The factory creates a shortcut, but to get the values it calls the method, so the Strings are needed.The best thing to do is to remove the tw Strings from the method and calculate or inject them in another part of the class. You didn't provide the whole code
so its just guessing where the values of the Strings come from. I assume they are directly retrieved from the page and you have the set's and get's in your bean already.So basically :
private String msisdn; private String instCode; // Sets and gets @Factory("topUpTrList") public List<MobeeTopupTr> retrieveAllTr(){ return topUpTrList = airtimeDatabase.createQuery("from mobeeTopUpTr tr where tr.msisdn=:MSISDN and tr.instId=:INSTCODE") .setParameter("MSISDN", msisdn).setParameter("INSTCODE", instCode).getResultList(); }
Hopefully this helps.
Leo
-
4. Re: Create Search
lvdberg Sep 22, 2011 8:34 AM (in response to pradeep6336)Hi,
additionally: Be careful with the rendered attribute of the different elements. When there is NO result there will be nothing, so it can't be re-rendered either.
Use a small trick with the seam-span or seam-div tags. They always render something, so it can be -re-rendered.Leo
-
5. Re: Create Search
pradeep6336 Sep 22, 2011 9:01 AM (in response to pradeep6336)thanks for the fast replay neo,
the
msisdn
andinstCode
comming from mobeeTopUpTr table,and i put the
<a:commandButtom .... .... reRender="searchTr" </a:commandButton> <s:span id="searchTr"> <h:dataTable... .... .... </s:span>
but it dit'nt work
-
6. Re: Create Search
lvdberg Sep 22, 2011 9:14 AM (in response to pradeep6336)Hi,
put an ajax-outputPanel around the s-span and gibve it an ID. Use that ID for the reRender.
So:
<a4j:outputPanel id="yourID" > <s:span id="searchTr"> <h:dataTable... .... .... </s:span> </a4j:outputPanel> and <a:commandButtom .... .... reRender="yourId" </a:commandButton>
Besides this, make sure there is a result, so instead of returning with the list.
Query q = airtimeDatabase.createQuery("from mobeeTopUpTr tr where tr.msisdn=:MSISDN and tr.instId=:INSTCODE"); q.setParameter("MSISDN", msisdn); q.setParameter("INSTCODE", instCode); List<mobeeTopUpTr> result = q.getResultList(); log.info("I retrieved " + result.size() " entities"); return result;
A lot more typing, but you can see what you're doing, Now you can see if the result gets you the data and i there is something for the databale to show.
Leo