You need to sign in to do that
Don't have an account?
java.lang.IllegalArgumentException error
I'm trying to create a simple app while learning visualforce/apex. I'm creating a table of movies available to rent and want to have a button for each movie allowing you to rent that movie and passing the movie name to a method that will remove one from the inventory. I'm still working on it but I'm getting a java.lang.IllegalArgumentException error when I click the button and not sure where im going wrong. I'm sure there's probably an obvious error in my approach but any help would be great!
Here's a code snippet of the column containing the rent button:
<apex:column headerValue="Rent Movie"> <apex:commandButton action="!Rent" value="Rent {!movie_item.name}"> <apex:param name="id" value="{!movie_item.name}" /> </apex:commandButton> </apex:column>
here's my apex code in my controller extension:
public class MovieRentalExtension { private final Movie__c movie; public MovieRentalExtension(ApexPages.StandardSetController controller) { this.movie = (Movie__c)controller.getRecord(); } public void Rent() { Id id = System.currentPageReference().getParameters().get('id'); // rent movie code } }
The command button action needs merge syntax I'd say:
All Answers
The command button action needs merge syntax I'd say:
Thanks for the help Bob!
I've continued to stumble through trying to figure this out and I'm stuck again. Let me know if the way I'm going about it even makes sense. I'm trying to assign MovieRented to be the movie that they've selected, then decrement the inventory by 1.
VF:
You'll need to have a rerender attribute to pass the parameter back to the controller. I'd also use the assignTo attribute rather than interrogating the url, and finally its better to use an id to identify a record as that will be unique:
replacing tableIdHere with the component id of the table from the page.