Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8198493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:57:45+00:00 2026-06-07T05:57:45+00:00

I have the following code that defines a getParts method to find a given

  • 0

I have the following code that defines a getParts method to find a given Part Name and Part Number in the system. Note that this code comes from our system’s API, so if no one can help I’ll just delete this question. I figured someone could potentially see a solution or help me along the way.

<%! private QueryResult getParts( String name, String number )
        throws WTException, WTPropertyVetoException {

    Class cname = wt.part.WTPart.class;
    QuerySpec qs = new QuerySpec(cname);
    QueryResult qr = null;

    qs.appendWhere
        (new SearchCondition(cname,
                                 "master>name",
                                 SearchCondition.EQUAL,
                                 name, 
                                 false));
    qs.appendAnd();
    qs.appendWhere
        (new SearchCondition(cname,
                                 "master>number",
                                 SearchCondition.EQUAL,
                                 number, 
                                 false));


    qr = PersistenceHelper.manager.find(qs);

    System.out.println("...found: " + qr.size());

    return qr;
}
%>

But I would like to allow the user more flexibility in finding these parts. So I set up conditional statements to check for a radio button. This allows them to search by part name and part number, find all, or search using a wildcard. However, I’m having trouble implementing the two latter options.

To attempt to accomplish the above, I have written the below code:

<% 
String partName = request.getParameter("nameInput");
String partNumber = request.getParameter("numberInput");
String searchMethod = request.getParameter("selection");

//out.print(searchMethod);

QueryResult myResult = new QueryResult();

if(searchMethod.equals("search"))
    myResult = getParts(partName, partNumber);

else if(searchMethod.equals("all"))
{
    //Should I write a new function and do this?
    //myResult = getAllParts();
    //or is there a way I could use a for each loop to accomplish this?

}

//else if(searchMethod.equals("wildcard"))
    //get parts matching %wildcard%


while(myResult.hasMoreElements())
{
        out.print(myResult.nextElement().toString());
}

%>

Basically, it accepts user input and checks what type of search they would like to perform. Is there an easy way to pass all the values into the myResult object? And likewise for the wildcard search? Like I said before, it may be futile trying to help without access to the API, but hopefully it isn’t.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:57:47+00:00Added an answer on June 7, 2026 at 5:57 am

    You can (and should) reuse the function, but in order to do so, you will need a part name and number (as those are its input parameters). So for the multi-result options you will need to get a list/collection of part names+numbers and feed them individually to the function, then collect the result in the format that is most appropriate for your needs

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code that I am compiling in a .NET 4.0 project namespace
I have following code that does not work due to a being a value
I have following code that does not work: I never get to goToFoodDetail .
I have following code snippet that i use to compile class at the run
I have the following code that has @item.ID from razor: <a href=# id=deleteitem(@item.ID)>Delete</a> When
I have the following code that gets the MAC address of an interface: static
I have the following code that opens a new popup window while disabling the
I have the following code that fails when i run it. my .h file:
I have the following code that returns a .CSV file when a link is
I have the following code that works fine up to the last line in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.