2

I am making a site in JRuby on Rails, I am using some Java classes as well.

I have a select form element which passes user selections to the controller.

The selections are passed like so:

Parameters: {"options"=>["Option One", "Option Two"]}

The Java method that I am using requires the options selected to be a String[] (Java String Array?)

I have tried using:

params[:options].to_java(:string)

This does not seem to work. Can someone point out what I am doing wrong and what I need to do convert the options to a Java String Array?

Thanks

Eef

1 Answer 1

3

params[:options] is a different key from params["options"], perhaps you really want params["options"]?

With that change, your code seems to work in jirb:

$ jirb --simple-prompt
>>  {"options"=>["Option One", "Option Two"]}["options"].to_java :string
=> [Ljava.lang.String;@107f742
>> 
Sign up to request clarification or add additional context in comments.

1 Comment

when you hit the submit button I have generally accessed anything passed to the controller with params, params[:options], I will your solution a try, thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.