Topic
7 replies Latest Post - ‏2013-01-03T15:03:31Z by DunnoJack
SystemAdmin
SystemAdmin
9029 Posts
ACCEPTED ANSWER

Pinned topic How to add a search filter in the List View

‏2012-12-31T06:12:58Z |
Based on a Tutorial I have completed CRUD based Application.

My List view which displays the List of Customers does not have a filter feature. The filter should be on Firstname. If user enters FirstName and Click on Go button, It should filter out the records for given Name.

I tried on my own to create Filter feature by following below steps

created SQl Call Builder with following sql

select CUSTREG_ID, FIRSTNAME, MIDDLENAME, LASTNAME, CUST_ID, EMAIL_ID from CUST_REGISTRATION where FIRSTNAME=?

Parameters being
Position=1
Direction=Input
Jdbc Typecast=Automatic
Value or Set/Cast method= ${Variables/searchCustRegListQueryInputs/FIRSTNAME}
Created a Service operatrion builder to execute above SQL query

Operation Results being
Result Schema= searchCustRegListQueryTransformSchema/RowSet

Above search feature is working fine in the service Model it filters out the records as per the Firstname
Need Help here for Consumer Model

In My consumer model
Created a Text Input name txtSerch and placed it above the List

Created Action List
How should my Action List be in steps?????

Created a Button Go with link to above action
Updated on 2013-01-03T15:03:31Z at 2013-01-03T15:03:31Z by DunnoJack
  • DunnoJack
    DunnoJack
    32 Posts
    ACCEPTED ANSWER

    Re: How to add a search filter in the List View

    ‏2012-12-31T20:50:26Z  in response to SystemAdmin
    When you run your application, do you see the text-input that you created on the screen?

    If not, then I think there is something wrong with how you have setup the form field.

    If it does, and you just aren't having the list narrow down when you submit the form, then...

    The value you are capturing with the text-input isn't being passed to the SQL Call Builder.

    The SQL Call Builder you described is looking for a value in ${Variables/searchCustRegListQueryInputs/FIRSTNAME}.

    So, you need to move whatever value is being captured by the text input into that variable.

    Your action list could be:
    1. Move value from text-input to SQL variable
    2. Call method to get results
    3. call display page

    Alternatively, I think there is a better approach to creating a search filter on your page.

    Instead of adding a text-input, you should add a Data Page builder. Point the data page variable attribute at your service operation's input schema. This builder will automatically create the form fields for you, and map their values to the SQL builder.

    Plus, this way, if you need to add more search criteria in the future, like a Last Name, then you only have to update the input schema, the Data Page will automatically add the new fields for you.
    • SystemAdmin
      SystemAdmin
      9029 Posts
      ACCEPTED ANSWER

      Re: How to add a search filter in the List View

      ‏2013-01-02T10:59:56Z  in response to DunnoJack
      Hi DunnoJack

      When you run your application, do you see the text-input that you created on the screen?
      Yes I am able to see the Text input and Go Button.

      I tried this in Action List but its not working
      1. Assignment!Variables/srchVar=${Java/webAppAccess.getRequestInputs().getInputValue("txtSerch")}
      2. Assignment!DataServices/CustomerRegistration/searchCustRegList/inputs/searchCustRegListQueryInputs/FIRSTNAME=${Variables/srchVar}
      3. DataServices/CustomerRegistration/searchCustRegList
      4. CustomerRegistrationView_ViewPage

      Its the same view page instead of filtered one.
      the below step you gave just passed over the head ..I didnt understand..the thing is View and Form Builder used in this consumer model already created a view page wherein I embedded my textBox and go Button. The filter should happen on same page.
      If below step is the best approach can you please explain. I am New to WEF and quite dependant on Tutorials. In normal coding this usecase is pretty simple :)

      Instead of adding a text-input, you should add a Data Page builder.
      Point the data page variable attribute at your service operation's input schema. This builder will automatically create the form fields for you, and map their values to the SQL builder.
      • mburati
        mburati
        2551 Posts
        ACCEPTED ANSWER

        Re: How to add a search filter in the List View

        ‏2013-01-02T15:25:30Z  in response to SystemAdmin
        It sounds like you may have a View and Form associated with one operation but then are executing a separate operation (your new search operation) and then displaying the view page associated with the original List operation.

        A general WEF best practice is to use the highest level builder available for the use case you are attempting to implement.

        For a CRUD based application with Search and/or Filter, the Data Services User interface (DSUI) builder (a superset of View and Form which adds full CRUD plus search and filter capabilities) would automate more of the solution for you, so that you do not have to mess around with low level control builders such as text input and button yourself. The DSUI builder expects a service provider with the logical crud operations defined (so it knows which operation is create vs list vs search etc) and the easiest way to do that for a DB based application is to build your provider with the SQL Data Services builder which will generate the SQL calls and the service operations and logical operation names for you (see the Search section of the SQL DS builder for how to specify which column(s) to search on).

        If you are new to WEF then it's best to get started with the provided tutorials and the Learning Roadmap and Samples catalog on the WEF Wiki (URL below). While there is a Redbook, it's fairly old and was produced before some of the latest high level builders were available and thus may not be up to date with these more recent best practices, so if you're starting off with the Redbook, you may wish to put it aside for a bit while going through the WEF Learning Roadmap on the wiki, and then go back to the Redbook if you wish, when you have more time.

        If you post a sample (with no confidential info or intellectual property) showing what you're having trouble with, it might make it easier for someone to quickly spot what's wrong with it.
        I hope that info helps,
        ..Mike Burati
        http://www-10.lotus.com/ldd/pfwiki.nsf/
        The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
        • SystemAdmin
          SystemAdmin
          9029 Posts
          ACCEPTED ANSWER

          Re: How to add a search filter in the List View

          ‏2013-01-03T13:25:10Z  in response to mburati
          Thanks Michael, I will surely try DSUI.
      • DunnoJack
        DunnoJack
        32 Posts
        ACCEPTED ANSWER

        Re: How to add a search filter in the List View

        ‏2013-01-02T22:49:31Z  in response to SystemAdmin
        Hey ManojJadav,

        I've been in your shoes before, trying to learn how to get things done with WebSphere. Attached is an example of what I was trying to explain. The combination of using a data page build for search criteria and (in your case view & form builder) to display the results.

        Good luck!
        • SystemAdmin
          SystemAdmin
          9029 Posts
          ACCEPTED ANSWER

          Re: How to add a search filter in the List View

          ‏2013-01-03T13:34:31Z  in response to DunnoJack
          Hi DunnoJack, I imported your models and the search filter was working fine but View All button wasn't. Thanks for the effort man, I am able to understand something.
          I'll have to try implementing your builders sequence for my consumer model. I will be updating this thread only By Next week, something else came up to tackle now :(
          • DunnoJack
            DunnoJack
            32 Posts
            ACCEPTED ANSWER

            Re: How to add a search filter in the List View

            ‏2013-01-03T15:03:31Z  in response to SystemAdmin
            Oops, I should have labeled "view all" something like "clear search" in my example (which is what it does). I pulled the code from a current project, and the company I'm working for right now likes that confusing label for some reason.