Paul Yule

Ranch Hand
+ Follow
since May 12, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Yule

I have a webApp that is generating a PDF. I'm looking for a way to write the PDF to a directory that only allows "User1" access to the folder. The password for "User1" is retrieved through a webservice using a stored key on the server. I don't know how I'm supposed to set the User/Password before writing the file to directory. Normally, I think this just uses the username and pass that the application was started under. I feel like I've looked everywhere for these options. Is this doable?
4 years ago
I have struts set up so that I can validate forms through validate and display messages from a properties file. IE:



I have added a filter onto the application to restrict certain roles from various pages and the logic is working correctly. However, because i don't have access to ActionMessages or ActionErrors I'm not sure how to display the message I want without hard coding the message in the filter logic.

So, I can do:



what I want is:



Any suggestions? I probably just can't see the forest for the trees thing but I'm at my wits end.
9 years ago
I am currently maintaining an App that has 1 complex pojo that gets pushed to the Session. The app has been working fine until we recently moved it to a clustered environment. Now we are seeing odd behavior with data being missing on certain pages that seems mostly sporadic. I assume this means it is happening when I am adding the object on one server and then another server handles the next request which has trouble getting the object off the session. From what I've been able to read around the interwebs is that the complex object that was being pushed to the session object needs to be serializable. I don't quite understand why. If it was reading and writing to the session before why does it have trouble getting when adding another server to the mix?
10 years ago
I'm making an ajax call that either returns xml written in a struts action or returns to the struts-config input jsp if the form doesn't validate. So I'd like to do something different if the return type is text/html. Is it possible to get the content type off of the XMLRequest object? Some code is included for reference.





Ok thanks.

So after changing the name to lineItems in the loop the html generated looks like:



When I submit the form I am throwing a BeanUtils.populate exception and I don't know what to try to change this too. I don't understand how it can retrieve the value off of the object but it won't set the value on the submit.

Any ideas?

10 years ago
I think what you are saying makes sense about the disconnect between the HTMl and the ActionForm. Replacing the name with lineItems gives me a BeanUtils.populate error which I'm assuming has to do with my lack of setter methods for the properties. For debugging purposes I tried with a name of asdasd and it threw the same NPE I was getting earlier. I read over the indexed properties section a time or two on Apache's site but I'm still confused. I'll attempt it and if I have concrete issues I'll reply.

Thanks David.


Edit: I think my link above was done correctly with the UBB tag. Maybe the changes for SEO I read about in the Ranch Office forums are related to it appearing incorrectly. Someone should verify it isn't user error though.
10 years ago
Hmm.. ok. Should I try to set the variable of the iterator to lineItems and replace the names inside as well? Would I need getters and setters for each property inside the LineItemsBean?
10 years ago

David Newton wrote:

Paul Yule wrote:upon submitting the form I get a NPE in my saveLineItems Action. Included below is the struts config that is relevant


Sure be easier if you told us where, so we at least have a place to start looking.



The error I'm receiving is a null pointer when I try to get the list of LineItems off of the form when I submit the page.





lineItems.size() throws NPE.
10 years ago
Hey I'm having an issue passing a form correctly to my action class. I'm afraid I've setup my form incorrectly. The form I am passing is a table of inputs from the user. There will be 2 select boxes and then 4 input text boxes. One row is equal to one LineItem java object with each input an attribute for the lineItem. So my form has an ArrayList of LineItems that I'm trying to pass.

The error I'm receiving is a null pointer when I try to get the list of LineItems off of the form when I submit the page.

First I call an action to initialize my lineItem array to 5 empty items and forward to my jsp to iterate over them for my input table.



The jsp below is the table for the lineItems. When I go to saveLineItems I pull the line items off the form and they are null and I get a NPE. For completeness the MainPageBean is a session bean that holds the list of options for the dropdown boxes. I have also included the html rendered on the page.


upon submitting the form I get a NPE in my saveLineItems Action. Included below is the struts config that is relevant

10 years ago
You mean I need to use <select> and what not for the javascript since the page is already rendered? Ok and how about the ArrayList of LineItems? How would I have an arraylist of LineItems inside the actionForm if I can't use iterate to index each parameter? If I just find out what is being rendered by the struts tag after it renders html can I just code that do you think?
10 years ago
so I'm wanting to do something like the following:



Where the javascript would generate the row for the table with one columns of the selects being a list of options. The user could put any number of rows in so I'd need a list of these rows. I don't know how to create a list of rows for submitting to the action form and how to set the property in the javascript there to the correct attribute for the bean or if it's even possible.
10 years ago

David Newton wrote:
Who's the big boy? Who's the big boy! You are! Yes you aaaarreee!



Thanks David. I appreciate that.


I used the ActionForm *only* for form input elements.



Ok, so you would put the list on the request as an attribute and use EL on the jsp to loop options?

I have a more complicated question. I have a table with 4 columns. userOption, From date, to Date, transactionId. I would like to make it so this table has 3 or 4 rows and then there is a button that will add a row to the table should they need additional rows through javascript. I envision this as a row on the html table represents an object. Lets call it lineItem with 4 attributes to each line item and then the form actionForm contains a list of lineItems. Can actionForms contain complex objects and then the property element on the html be something like lineItem.userId? I have been searching for similar requirements without much luck.

I'll word it a different way incase I'm as confusing as I figure I am. So ideally could I take a form that normally had a bunch of properties and instead the form has only 1 object with properties on the object. Secondly how would I then make it so the form could hold a list of those objects.
10 years ago
Ok, this is just general questions about stuff I'm hazy on and just talking about it from beginning to end "outloud" would really help I think. Pretend you're talking to a 5 yr old.

Say you have an action mapped inside your struts-config which has the following entry



And the Form that the action is referring to is here:



Now when I'm on Start.jsp (before this action is called) I have a form element with an action pointing to /main.do that has a userId element. So in my action I cast the form coming in to the type listed in the xml so I can use the getter:


Ok so lets say that on the next jsp (mainPage.jsp) there is a select box that has options populated by the userOptions from the LoadMainPageAction. The user selects an option and submits the form to a new action. So, in the new action I only need the selected option but I need the list of options on the jsp. Does the MainPageBean need to contain the list of userOptions?
10 years ago
Wow, thanks David. I must have stared at this thing for 4 hours before posting trying to go through every possible thing I could find and I still end up with an "Add a semicolon" solution.
10 years ago