[Stripes-users] Stripes framework radio button binding to ActionBean and defaults

2012-06-25 Thread William Krick
I can't seem to get the stripes:radio control to bind to my ActionBean.

Whenever my JSP loads, none of the radio buttons are selected.  I  
would like to be able to specify a default value so that when the JSP  
is loaded, one of the radio buttons are selected.

The stripes documentation indicates that the the "checked" value is  
pulled from the ActionBean, but I'm not seeing that happen.

Is there something subtle about the way stripes radio buttons work or  
the syntax that I'm missing?

I've tried to find working sample code on the internet, but everyone  
seems to be asking the same question as me but not getting any answers.



--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] Stripes framework radio button binding to ActionBean and defaults

2012-06-25 Thread William Krick
It doesn't seem to work.

I took the stripes calculator sample app and added the following lines:


ActionBean:

private String operationStr = "1";
public String getOperationStr() { return operationStr; }
public void setOperationStr(String operationStr) { this.operationStr =  
operationStr; }

private Boolean operationBool = true;
public Boolean getOperationBool() { return operationBool; }
public void setOperationBool(Boolean operationBool) {  
this.operationBool = operationBool; }


JSP:

One
Two

True
False


But when I launch the JSP, all radio buttons are unselected.



Quoting Mike McNally :

> Stripes will set a radio button to "checked" when its value matches
> the value of the property on the action bean.  Thus, if you've got
>
> 
>
> and your action bean has an "xyz" property whose value is 1, then that
> radio button will be checked.
>
>
> On Mon, Jun 25, 2012 at 12:25 PM, William Krick  wrote:
>> I can't seem to get the stripes:radio control to bind to my ActionBean.
>>
>> Whenever my JSP loads, none of the radio buttons are selected.  I
>> would like to be able to specify a default value so that when the JSP
>> is loaded, one of the radio buttons are selected.
>>
>> The stripes documentation indicates that the the "checked" value is
>> pulled from the ActionBean, but I'm not seeing that happen.
>>
>> Is there something subtle about the way stripes radio buttons work or
>> the syntax that I'm missing?
>>
>> I've tried to find working sample code on the internet, but everyone
>> seems to be asking the same question as me but not getting any answers.
>>
>>
>>
>> --
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> ___
>> Stripes-users mailing list
>> Stripes-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
>
> --
> Turtle, turtle, on the ground,
> Pink and shiny, turn around.
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] Stripes framework radio button binding to ActionBean and defaults

2012-06-25 Thread William Krick
The index.jsp is being linked directly from the quickstart index.html page.

I tried adding this to my ActionBean...

public Resolution launch() {
return new ForwardResolution("/quickstart/index.jsp");
}

And I changed the link in the index.html to...

http://localhost:8080/stripes-examples/quickstart/index.jsp?action=launch

...but that doesn't work either.  I'm sure I have the URL syntax wrong.


If it's not too much trouble, can you provide some sample  
ActionBean/JSP code to illustrate how this works?


Quoting Mike McNally :

> Are you getting to your JSP from a ForwardResolution from that action
> bean?  In my experience my action beans usually follow a pattern of
> having a "launch" action to return a ForwardResolution to the JSP
> (after possibly doing some work to initialize the bean), and then a
> "doSomething" action to handle the subsequent form post.
>
> If you're not getting to the JSP page from that same action bean, then
> it won't work.
>
> On Mon, Jun 25, 2012 at 1:37 PM, William Krick  wrote:
>> It doesn't seem to work.
>>
>> I took the stripes calculator sample app and added the following lines:
>>
>>
>> ActionBean:
>>
>> private String operationStr = "1";
>> public String getOperationStr() { return operationStr; }
>> public void setOperationStr(String operationStr) { this.operationStr =
>> operationStr; }
>>
>> private Boolean operationBool = true;
>> public Boolean getOperationBool() { return operationBool; }
>> public void setOperationBool(Boolean operationBool) {
>> this.operationBool = operationBool; }
>>
>>
>> JSP:
>>
>> One
>> Two
>>
>> True
>> False
>>
>>
>> But when I launch the JSP, all radio buttons are unselected.
>>
>>
>>
>> Quoting Mike McNally :
>>
>>> Stripes will set a radio button to "checked" when its value matches
>>> the value of the property on the action bean.  Thus, if you've got
>>>
>>>     
>>>
>>> and your action bean has an "xyz" property whose value is 1, then that
>>> radio button will be checked.
>>>
>>>
>>> On Mon, Jun 25, 2012 at 12:25 PM, William Krick  
>>>  wrote:
>>>> I can't seem to get the stripes:radio control to bind to my ActionBean.
>>>>
>>>> Whenever my JSP loads, none of the radio buttons are selected.  I
>>>> would like to be able to specify a default value so that when the JSP
>>>> is loaded, one of the radio buttons are selected.
>>>>
>>>> The stripes documentation indicates that the the "checked" value is
>>>> pulled from the ActionBean, but I'm not seeing that happen.
>>>>
>>>> Is there something subtle about the way stripes radio buttons work or
>>>> the syntax that I'm missing?
>>>>
>>>> I've tried to find working sample code on the internet, but everyone
>>>> seems to be asking the same question as me but not getting any answers.
>>>>
>>>>
>>>>
>>>> --
>>>> Live Security Virtual Conference
>>>> Exclusive live event will cover all the ways today's security and
>>>> threat landscape has changed and how IT managers can respond. Discussions
>>>> will include endpoint security, mobile security and the latest in malware
>>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>>> ___
>>>> Stripes-users mailing list
>>>> Stripes-users@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>>
>>>
>>>
>>> --
>>> Turtle, turtle, on the ground,
>>> Pink and shiny, turn around.
>>>
>>> --
>>> Live Security Virtual Conference
>>> Exclusive live event will cover all the ways today's security and
>>> threat landscape has changed and how IT managers can respond. Discussions
>>> will include endpoint security, mobile security and the latest in malware
>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>> ___
>>> Stripes-users mailing list
>>> Stripes-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/list

Re: [Stripes-users] Stripes framework radio button binding to ActionBean and defaults

2012-06-25 Thread William Krick
I'm using the sample calculator app that comes with the stripes  
package download.

The sample app already works.  It has an ActionBean called  
"CalculatorActionBean.java".  I assume that everything should be set  
up already regarding the web.xml or the app wouldn't work.

All I'm trying to do is add radio buttons to the page and have one of  
them default to selected.

It's obvious now that the problem is that the stripes examples html  
page is launching the calculator app by calling the JSP file directly.  
  However, I tried changing it to call the ActionBean, but that  
doesn't resolve correctly for reasons that I don't understand.

I added this to web.xml...


 ActionResolver.Packages
 net.sourceforge.stripes.examples.quickstart


...because that's the package that contains CalculatorActionBean.java  
but that doesn't help either.



Quoting Cristian C :

> I suggest you read this book if you're serious about understanding Stripes,
>
> http://pragprog.com/book/fdstr/stripes
>
> Where you're going:
> http://localhost:8080/stripes-examples/quickstart/index.jsp?action=launch
> is wrong.
>
> You need to access the action bean not the JSP directly, which would
> be a call such as
>
> http://localhost:8080/stripes-examples/quickstart/Hello.action
>
> This would work provided you have HelloActionBean.java which extends
> ActionBean and is set up in web.xml properly for stripes to find it,
> ex.
>  
> ActionResolver.Packages
> net.sourceforge.stripes.examples
> 
>
> With no params the action would go to the method annonated with
> @DefaultHandler, such as
> @DefaultHandler
>   public Resolution view() {
>   return new ForwardResolution("example.jsp");
>   }
>
>
> Check out the Bugzooky example.. it has almost everything you'll ever need.
>
>
>
>
> On Mon, Jun 25, 2012 at 3:02 PM, William Krick  wrote:
>> The index.jsp is being linked directly from the quickstart index.html page.
>>
>> I tried adding this to my ActionBean...
>>
>> public Resolution launch() {
>>        return new ForwardResolution("/quickstart/index.jsp");
>> }
>>
>> And I changed the link in the index.html to...
>>
>> http://localhost:8080/stripes-examples/quickstart/index.jsp?action=launch
>>
>> ...but that doesn't work either.  I'm sure I have the URL syntax wrong.
>>
>>
>> If it's not too much trouble, can you provide some sample
>> ActionBean/JSP code to illustrate how this works?
>>
>>
>> Quoting Mike McNally :
>>
>>> Are you getting to your JSP from a ForwardResolution from that action
>>> bean?  In my experience my action beans usually follow a pattern of
>>> having a "launch" action to return a ForwardResolution to the JSP
>>> (after possibly doing some work to initialize the bean), and then a
>>> "doSomething" action to handle the subsequent form post.
>>>
>>> If you're not getting to the JSP page from that same action bean, then
>>> it won't work.
>>>
>>> On Mon, Jun 25, 2012 at 1:37 PM, William Krick  
>>>  wrote:
>>>> It doesn't seem to work.
>>>>
>>>> I took the stripes calculator sample app and added the following lines:
>>>>
>>>>
>>>> ActionBean:
>>>>
>>>> private String operationStr = "1";
>>>> public String getOperationStr() { return operationStr; }
>>>> public void setOperationStr(String operationStr) { this.operationStr =
>>>> operationStr; }
>>>>
>>>> private Boolean operationBool = true;
>>>> public Boolean getOperationBool() { return operationBool; }
>>>> public void setOperationBool(Boolean operationBool) {
>>>> this.operationBool = operationBool; }
>>>>
>>>>
>>>> JSP:
>>>>
>>>> One
>>>> Two
>>>>
>>>> True
>>>> False
>>>>
>>>>
>>>> But when I launch the JSP, all radio buttons are unselected.
>>>>
>>>>
>>>>
>>>> Quoting Mike McNally :
>>>>
>>>>> Stripes will set a radio button to "checked" when its value matches
>>>>> the value of the property on the action bean.  Thus, if you've got
>>>>>
>>>>>     
>>>>>
>>>>> and your action bean has an "xyz" property whose value is 1, then that

[Stripes-users] StreamingResolution, temporary files, and Exceptions

2014-06-23 Thread William Krick
In my web application, I have code that generates a temporary file (based
on user input) and streams it back to the user using a StreamingResolution.

The initial implementation had a utility method that generated the file and
passed back an InputStream...

public Resolution exportCsv() throws IOException {
  InputStream is = getCsvData();
  StreamingResolution sr = new
StreamingResolution(Constants.CONTENT_TYPE_CSV, is);
  sr.setFilename("export.csv");
  return sr;
}

However, I want to be able to clean up the temporary file after it has been
streamed to the user.
I thought that I could use the anonymous inner class method described in
the stripes javadocs...

public Resolution exportCsv() throws IOException {
  return new StreamingResolution(Constants.CONTENT_TYPE_CSV) {
public void stream(HttpServletResponse response) throws Exception {
  File tempFile = null;
  InputStream is = null;
  try {
tempFile = File.createTempFile(UUID.randomUUID().toString(), null);
getCsvData(tempFile);
is = new FileInputStream(tempFile);
IOUtils.copy(is, response.getOutputStream());
is.close();
  }
  catch(IOException e) {
logger.error("Unable to export to csv file: " + e);
throw new IOException();
  }
  finally {
IOUtils.closeQuietly(is);
FileUtils.deleteQuietly(tempFile);
  }
}
  }.setFilename("export.csv");
}


I'm finding that if there's an exception, whatever error page my
application generates gets streamed back to the user in a file called
"export.csv".  So this method isn't really viable, at least the way I'm
using it.

Is there a pattern for this sort of thing in Stripes?
--
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


[Stripes-users] JSP expression language and stripes framework

2014-11-21 Thread William Krick
In a JSP, I can do something like this to display a value from the action
bean...

Hello ${actionBean.person.name } 


I'm trying to figure out how to display alternate text in the jsp if the
value from the actionBean is null, but I can't figure out any syntax that
works.  I was expecting something like this to work, but that doesn't seem
to be the case...


Hello ${ (actionBean.person.name  !=
null) ? actionBean.person.name  : 'valued
customer'} 


Is something like this possible, or do I need to write a method in the
actionBean that does this logic and returns the appropriate string?
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] JSP expression language and stripes framework

2014-11-21 Thread William Krick
I hadn't thought about using JSTL.

Then I could also do something like this (using "empty" in the test as
suggested by Mike McNally)...

http://actionbean.person.name/> ? 'valued customer' :
actionBean.person.name  }"/>

On Fri, Nov 21, 2014 at 5:38 PM, Joaquin Valdez 
wrote:

> I do this using JSTL but I am sure there is a better way:
>
> 
>// do something...
> 
> http://actionbean.person.name/>} 
>
>
> I'm trying to figure out how to display alternate text in the jsp if the
> value from the actionBean is null, but I can't figure out any syntax that
> works.  I was expecting something like this to work, but that doesn't seem
> to be the case...
>
>
> Hello ${ (actionBean.person.name  !=
> null) ? actionBean.person.name  : 'valued
> customer'} 
>
>
> Is something like this possible, or do I need to write a method in the
> actionBean that does this logic and returns the appropriate string?
>
> --
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk___
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
>
>
> --
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
> ___
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


[Stripes-users] Preserving unbound values on save

2014-11-26 Thread William Krick
I have a situation where I have a JSP form and it is populated with values
from an object pulled from a database.

Below is some sample code off the top of my head.  It might not compile.
The names have been changed to protect the innocent.

The problem I'm having is that the Customer object contains a lot more
fields than are displayed on the page for the user to edit.  And when the
user saves the page, anything not explicitly named on the page and bound to
the customer object in the action bean gets set to null.

I know that I can add hidden tags on the page as a way to deal with this,
but there's a lot of extra un-bound fields in the Customer object, and I
really don't want to add a bunch of hidden tags.  Plus, this exposes the
data in those fields to any user who views the source on the html page.

The Customer object was designed to mirror the database model, but the user
view into that model isn't 100% of the data.

This has to be a common problem.  Ideally, I'd like to have something where
unbound members of the customer object are just left with their original
values.  Short of maintaining two separate Customer objects, one for the
screen and one for the database and juggling data back and forth between
the two, is there a way to deal with this situation?



public class EditCustomerAction extends BaseAction {

private Long customerId;
private Customer customer;

@DefaultHandler
public Resolution view() {
if (customerId != null) {
customer = CustomerClient.getInstance().retrieveCustomer(customerId);
}
return new ForwardResolution(EDIT_CUSTOMER_JSP);
}

public Resolution save() {
if (customer != null && customerId != null) {
CustomerClient.getInstance().updateCustomer(customerId, customer);
}
return new RedirectResolution(NEXT_JSP);
}

public Resolution cancel() {
return new RedirectResolution(PREV_JSP);
}

public Long getCustomerId() { return customerId; }

public void setCustomerId(Long customerId) { this.customerId = customerId; }

public Customer getCustomer() { return customer; }

public void setCustomer(Customer customer) { this.customer = customer; }

}
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


[Stripes-users] using stripes select just for the collection feature

2015-03-17 Thread William Krick
I have a  that I'm using to provide a list of items to the
user using the .

When an item is selected in the list, some javascript is triggered that
adds some on-screen text to a table along with some hidden input tags that
get submitted with the page.

However, the actual value currently selected in the  isn't
important and I don't need or want it to be submitted.  The only reason I'm
suing  is to take advantage of the collection population
feature.

The problem I'm having is that  requires a name.
If you leave the name blank like this...





...you get an error when you submit...

[DefaultActionBeanPropertyBinder] Could not bind property with name [] to
bean of type...

...followed by a NullPointerException.


However, if you give it a dummy name like this...





...you get a different error when the page loads...

[DefaultPopulationStrategy] Could not find property [dummyName] on ...


Obviously, out of the two choices, the second option is better because it
doesn't cause an exception, but I was wondering if other people are using
 this way and how they deal with the warnings/errors or if
they just ignore them.

I even tried this...





...but that throws an exception when the page loads...

net.sourceforge.stripes.exception.StripesJspException: Option tags must
always be contained inside a select tag.
--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] StreamingResolution, temporary files, and Exceptions

2015-07-09 Thread William Krick
Sorry to dig up an old thread but I was working on another project for a
while and now I'm coming back to the original project and the
StreamingResolution issue.

The hybrid solution posted by Ben Gunter seems to work well.  Thank you.

I have two questions/concerns.

1) I see why tempFile needs to be declared final (to access it inside of
the StreamingResolution), and I also see why it needs to be an array where
we reference item 0 (to get around it being final for the method that
populates the temp file and creates the InputStream), but it really looks
and feels like a hack.  Isn't there a better way to do this that isn't so
hacky?

2) I'm doing this same thing (populating a temp file, streaming it to the
user, deleting the temp file) in a lot of places in a multi-page web
application.  Is there a clean way to encapsulate these 20-something lines
of code into a class so that I'm not copy/pasting boilerplate code over and
over again?

Thanks


On Tue, Jun 24, 2014 at 8:25 AM, Ben Gunter  wrote:

> Yes, sort of a hybrid of your two approaches.
>
> public Resolution exportCsv() throws IOException {
> final File tempFile[] = { null };
> final InputStream is;
> try {
> tempFile[0] =
> File.createTempFile(UUID.randomUUID().toString(), null);
> getCsvData(tempFile[0]);
> is = new FileInputStream(tempFile[0]);
> } catch (IOException e) {
> logger.error("Unable to export to csv file: " + e);
> throw new IOException();
> } finally {
> FileUtils.deleteQuietly(tempFile[0]);
> }
>
> return new StreamingResolution(Constants.CONTENT_TYPE_CSV, is) {
> public void stream(HttpServletResponse response) throws
> Exception {
> try {
> super.stream(response);
> } finally {
> FileUtils.deleteQuietly(tempFile[0]);
>     }
> }
> }.setFilename("export.csv");
> }
>
>
> On Mon, Jun 23, 2014 at 5:33 PM, William Krick 
> wrote:
>
>> In my web application, I have code that generates a temporary file (based
>> on user input) and streams it back to the user using a StreamingResolution.
>>
>> The initial implementation had a utility method that generated the file
>> and passed back an InputStream...
>>
>> public Resolution exportCsv() throws IOException {
>>   InputStream is = getCsvData();
>>   StreamingResolution sr = new
>> StreamingResolution(Constants.CONTENT_TYPE_CSV, is);
>>   sr.setFilename("export.csv");
>>   return sr;
>> }
>>
>> However, I want to be able to clean up the temporary file after it has
>> been streamed to the user.
>> I thought that I could use the anonymous inner class method described in
>> the stripes javadocs...
>>
>> public Resolution exportCsv() throws IOException {
>>   return new StreamingResolution(Constants.CONTENT_TYPE_CSV) {
>> public void stream(HttpServletResponse response) throws Exception {
>>   File tempFile = null;
>>   InputStream is = null;
>>   try {
>> tempFile = File.createTempFile(UUID.randomUUID().toString(),
>> null);
>> getCsvData(tempFile);
>> is = new FileInputStream(tempFile);
>> IOUtils.copy(is, response.getOutputStream());
>> is.close();
>>   }
>>   catch(IOException e) {
>> logger.error("Unable to export to csv file: " + e);
>> throw new IOException();
>>   }
>>   finally {
>> IOUtils.closeQuietly(is);
>> FileUtils.deleteQuietly(tempFile);
>>   }
>> }
>>   }.setFilename("export.csv");
>> }
>>
>>
>> I'm finding that if there's an exception, whatever error page my
>> application generates gets streamed back to the user in a file called
>> "export.csv".  So this method isn't really viable, at least the way I'm
>> using it.
>>
>> Is there a pattern for this sort of thing in Stripes?
>>
>>
>>
>>
>> --
>> Open source business process management suite built on Java and Eclipse
>> Turn processes into business applications with Bonita BPM Community
>> Edition
>> Quickly connect people, data, and systems into organized workflows
>> Winner of BOSSIE, CODIE, OW2 and Gartner awards
>> http://p.sf.net/sfu/Bonitasoft
>> ___
>> Stripes-users

Re: [Stripes-users] StreamingResolution, temporary files, and Exceptions

2015-07-13 Thread William Krick
I noticed something odd.  I'm not sure if it's a bug or user error.

When I set the filename OUTSIDE, it works as expected...

return new StreamingResolution(Constants.CONTENT_TYPE_CSV, is) {
public void stream(HttpServletResponse response) throws
Exception {
try {
super.stream(response);
} finally {
FileUtils.deleteQuietly(tempFile[0]);
}
}
}.setFilename("export.csv");


But if I set the filename INSIDE like this, the ".csv" gets cut off the end
of the filename on the download...

return new StreamingResolution(Constants.CONTENT_TYPE_CSV, is) {
public void stream(HttpServletResponse response) throws
Exception {
this.setFilename("export.csv");
try {
super.stream(response);
} finally {
FileUtils.deleteQuietly(tempFile[0]);
}
}
};



On Thu, Jul 9, 2015 at 7:50 PM, Nestor Hernandez  wrote:

> In any case the solution I posted works
>
> 1. Existing file
>
> getExportCsv(outpustream) {
> File file =  ...
> Inputstream in = null;
> try{
> in = new FileInpustream(file);
> IOUtils.copy(in, outpustream)
> } finally{
>   IOUtils.closeQuietly(in);
> }
> }
>
> 2. Just write to the outpustream
> El 9/7/2015 18:34, "Rick Grashel"  escribió:
>
>> I could be wrong, but it sounded to me like he was generating the CSV
>> file on the filesystem based on user-input.  So it could be a file being
>> created out of the database.  If the CSV file can be very large, he
>> definitely should keep it on the file system and use buffered streams to
>> send it back to the client.  Otherwise, he stands to consume a lot of
>> memory on the server which is bad.
>>
>> It's very easy to delete the temporary file in a finally block with a
>> high confidence that the deletion won't fail.
>>
>> -- Rick
>>
>>
>> On Thu, Jul 9, 2015 at 6:27 PM, Nestor Hernandez 
>> wrote:
>>
>>> Your method getExportCsv could be like this:
>>>
>>> getExportCsv (outpustream){
>>>//Write to the outpustream
>>> }
>>>
>>> And there is no need of temp files !
>>> Cheers
>>> El 9/7/2015 18:07, "Nestor Hernandez"  escribió:
>>>
>>>> Well, I think that that could be much better like this. Just write to
>>>> the response outpustream.
>>>>
>>>> return new StreamingResolution() {
>>>> public void stream(request, response){
>>>>  getExportCsv(response.getOutputstream());
>>>> }
>>>> }
>>>> El 9/7/2015 17:48, "William Krick"  escribió:
>>>>
>>>>> Sorry to dig up an old thread but I was working on another project for
>>>>> a while and now I'm coming back to the original project and the
>>>>> StreamingResolution issue.
>>>>>
>>>>> The hybrid solution posted by Ben Gunter seems to work well.  Thank
>>>>> you.
>>>>>
>>>>> I have two questions/concerns.
>>>>>
>>>>> 1) I see why tempFile needs to be declared final (to access it inside
>>>>> of the StreamingResolution), and I also see why it needs to be an array
>>>>> where we reference item 0 (to get around it being final for the method 
>>>>> that
>>>>> populates the temp file and creates the InputStream), but it really looks
>>>>> and feels like a hack.  Isn't there a better way to do this that isn't so
>>>>> hacky?
>>>>>
>>>>> 2) I'm doing this same thing (populating a temp file, streaming it to
>>>>> the user, deleting the temp file) in a lot of places in a multi-page web
>>>>> application.  Is there a clean way to encapsulate these 20-something lines
>>>>> of code into a class so that I'm not copy/pasting boilerplate code over 
>>>>> and
>>>>> over again?
>>>>>
>>>>> Thanks
>>>>>
>>>>>
>>>>> On Tue, Jun 24, 2014 at 8:25 AM, Ben Gunter  wrote:
>>>>>
>>>>>> Yes, sort of a hybrid of your two approaches.
>>>>>>
>>>>>> public Resolution exportCsv() throws IOException {
>>>>>> final File tempFile[] = { null };
>>>>>> final InputStream is;
>>>>>

[Stripes-users] clearing form values before ForwardResolution

2015-07-22 Thread William Krick
I have a situation where I'm submitting a form with search parameters,
performing a database search, and forwarding to the same page with the
results of the search displayed in a table beneath the form input fields
with all the search parameters.  Pretty standard stuff, really.

The problem I'm having is that there's a radio button group (and possibly a
few other fields) on the form that I would like to clear after a successful
search but I can't figure out how to do it.  Setting the various values to
null in the ActionBean before returning the ForwardResolution isn't working.

I also tried doing this, which didn't work either...

getContext().getRequest().setAttribute("assignToSelection", null);

What's the correct way to clear form values in the action bean?
--
___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] clearing form values before ForwardResolution

2015-07-22 Thread William Krick
@Andy
This is an existing large project in a production environment.  So I can't
change the population strategy at this point.  The risk of introducing new
and exciting bugs it too great.  One of the comments on StackOverflow
suggests using RedirectResolution instead of ForwardResolution but I'm not
sure if that's a viable option given the existing code I'm modifying.

@Rick
I've already tried doing exactly as you suggest, setting the value to null,
but it doesn't work.

On Wed, Jul 22, 2015 at 11:45 AM, Rick Grashel  wrote:

> Hi William,
>
> All you should need to do is just set the actual variable to null in the
> action bean before you return the resolution.
>
> So let's say the name of the control on the search form was "firstName".
> That means that in the event handler method, you would have this line of
> code:
>
> this.firstName = null;
> return new ForwardResolution( "/whatever_page.jsp" );
>
> If it is a nested property on a first class object, then you can do
> something like this:
>
> searchCriteria.setFirstName( null );
> return new ForwardResolution( "/whatever_page.jsp" );
>
> That should do what you are looking for.  Hope this helps.
>
> -- Rick
>
>
>
> On Wed, Jul 22, 2015 at 10:14 AM, William Krick 
> wrote:
>
>> I have a situation where I'm submitting a form with search parameters,
>> performing a database search, and forwarding to the same page with the
>> results of the search displayed in a table beneath the form input fields
>> with all the search parameters.  Pretty standard stuff, really.
>>
>> The problem I'm having is that there's a radio button group (and possibly
>> a few other fields) on the form that I would like to clear after a
>> successful search but I can't figure out how to do it.  Setting the various
>> values to null in the ActionBean before returning the ForwardResolution
>> isn't working.
>>
>> I also tried doing this, which didn't work either...
>>
>> getContext().getRequest().setAttribute("assignToSelection", null);
>>
>> What's the correct way to clear form values in the action bean?
>>
>>
>> --
>>
>> ___
>> Stripes-users mailing list
>> Stripes-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>>
>
>
> --
>
> ___
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
--
___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] clearing form values before ForwardResolution

2015-07-22 Thread William Krick
I believe the app is using the DefaultPopulationStrategy except for a few
pages that are annotated with...

@CustomPopulationStrategy(BeanFirstPopulationStrategy.class)

On Wed, Jul 22, 2015 at 1:00 PM, Rick Grashel  wrote:

> William,
>
> What population strategy are you using?  That's definitely going to drive
> the method for clearing out bean fields.
>
> -- Rick
>
> On Wed, Jul 22, 2015 at 11:54 AM, William Krick 
> wrote:
>
>> @Andy
>> This is an existing large project in a production environment.  So I
>> can't change the population strategy at this point.  The risk of
>> introducing new and exciting bugs it too great.  One of the comments on
>> StackOverflow suggests using RedirectResolution instead of
>> ForwardResolution but I'm not sure if that's a viable option given the
>> existing code I'm modifying.
>>
>> @Rick
>> I've already tried doing exactly as you suggest, setting the value to
>> null, but it doesn't work.
>>
>> On Wed, Jul 22, 2015 at 11:45 AM, Rick Grashel 
>> wrote:
>>
>>> Hi William,
>>>
>>> All you should need to do is just set the actual variable to null in the
>>> action bean before you return the resolution.
>>>
>>> So let's say the name of the control on the search form was
>>> "firstName".  That means that in the event handler method, you would have
>>> this line of code:
>>>
>>> this.firstName = null;
>>> return new ForwardResolution( "/whatever_page.jsp" );
>>>
>>> If it is a nested property on a first class object, then you can do
>>> something like this:
>>>
>>> searchCriteria.setFirstName( null );
>>> return new ForwardResolution( "/whatever_page.jsp" );
>>>
>>> That should do what you are looking for.  Hope this helps.
>>>
>>> -- Rick
>>>
>>>
>>>
>>> On Wed, Jul 22, 2015 at 10:14 AM, William Krick 
>>> wrote:
>>>
>>>> I have a situation where I'm submitting a form with search parameters,
>>>> performing a database search, and forwarding to the same page with the
>>>> results of the search displayed in a table beneath the form input fields
>>>> with all the search parameters.  Pretty standard stuff, really.
>>>>
>>>> The problem I'm having is that there's a radio button group (and
>>>> possibly a few other fields) on the form that I would like to clear after a
>>>> successful search but I can't figure out how to do it.  Setting the various
>>>> values to null in the ActionBean before returning the ForwardResolution
>>>> isn't working.
>>>>
>>>> I also tried doing this, which didn't work either...
>>>>
>>>> getContext().getRequest().setAttribute("assignToSelection", null);
>>>>
>>>> What's the correct way to clear form values in the action bean?
>>>>
>>>>
>>>> --
>>>>
>>>> ___
>>>> Stripes-users mailing list
>>>> Stripes-users@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>>>
>>>>
>>>
>>>
>>> --
>>>
>>> ___
>>> Stripes-users mailing list
>>> Stripes-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>>
>>>
>>
>>
>> --
>>
>> ___
>> Stripes-users mailing list
>> Stripes-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>>
>
>
> --
>
> ___
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
--
___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


[Stripes-users] Validation highlighting items in a multi-select list.

2015-08-04 Thread William Krick
I have an app that displays items in a select list that supports
multi-select...






The user can add new items (strings) to the list (via javascript) before
submitting and I'm trying to validate the added items.  Note that I have
javascript code that sets all the items to selected in the list before
submitting.

Currently, I'm able to display a validation error and highlight the whole
list by doing this in my action bean...

errors.add( "items", new SimpleError("list contains invalid item(s)") );

But I can't figure out the syntax to highlight specific items in the list.
I'm looping over the items in the list during validation and I thought this
might work, but it doesn't...

errors.add( "items[" + i + "]'", new SimpleError(i + " is not valid") );

Does anyone know the syntax to make this work?
--
___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


[Stripes-users] Stripes Framework + Knockout.js

2016-01-11 Thread William Krick
Is anyone using Stripes and Knockout together?
--
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


[Stripes-users] stripes tag for escaped string literal in JavaScript

2016-06-28 Thread William Krick
I've run into an interesting situation with un-escaped double quotes in
JavaScript in a JSP.


I have some JavaScript code like this...


var companyName = "${actionBean.company.name}";


...which breaks if the company name contains double quotes.

The same situation can happen if the company name contains a single quote
and the javascript code quotes using single quotes...

var companyName = '${actionBean.company.name}';


The only workaround I've been able to come up with involves adding new
methods to the company object that I can call to get a JavaScript escaped
version of the string using Apache
commons StringEscapeUtils.escapeJavaScript().
--
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] stripes tag for escaped string literal in JavaScript

2016-06-29 Thread William Krick
That's actually a really good idea.  I hadn't considered using a hidden
field or span.  Thanks for the tip.

On Wed, Jun 29, 2016 at 6:00 AM, Stan Broné  wrote:

> Personally I like to output these values in a hidden form field, or a
> span with style "display: none;". And then grab the values from in
> JavaScript by using DOM functions.
>
> It might not be as efficient, but I think the code is a bit cleaner
> and it solves your problem.
>
> -Stan
>
>
> Citeren James Jory :
>
> > We wrote a custom taglib function called escapeJS to handle this
> > from our JSPs and to keep JSP-specific code from polluting our model
> >  classes.
> >
> >
> >
> > var companyName = '${vt:escapeJS(actionBean.company.name)}';
> >
> >
> >
> > It just wraps a call to StringEscapeUtils.escapeEcmaScript().
> >
> >
> >
> > -James
> >
> >
> >
> > From: William Krick 
> > Reply-To: Stripes Users List 
> > Date: Tuesday, June 28, 2016 at 11:05 AM
> > To: Stripes Users List 
> > Subject: [Stripes-users] stripes tag for escaped string literal in
> JavaScript
> >
> >
> >
> > I've run into an interesting situation with un-escaped double quotes
> >  in JavaScript in a JSP.
> >
> >
> >
> >
> >
> > I have some JavaScript code like this...
> >
> >
> >
> >
> >
> > var companyName = "${actionBean.company.name}";
> >
> >
> >
> >
> >
> > ...which breaks if the company name contains double quotes.
> >
> >
> >
> > The same situation can happen if the company name contains a single
> > quote and the javascript code quotes using single quotes...
> >
> >
> >
> > var companyName = '${actionBean.company.name}';
> >
> >
> >
> >
> >
> > The only workaround I've been able to come up with involves adding
> > new methods to the company object that I can call to get a
> > JavaScript escaped version of the string using Apache commons
> > StringEscapeUtils.escapeJavaScript().
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> --
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape___
> Stripes-users mailing list Stripes-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/stripes-users
> >
> >
>
>
>
>
> --
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> ___
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
--
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


[Stripes-users] Strips user access control of linked files

2016-11-28 Thread William Krick
I'm working on a Stripes web application that provides links to tutorial
files.  The users have to log into the application.  The problem is that
the links to the tutorial files are accessible to anyone, whether they are
logged into the application or not.

The links should only be accessible to logged-in users.

Is there some standard way that this is done?

Also, should the files be hosted outside of the web-accessible root
directory?

I don't want to have to bundle the files inside the deployment war because
they may need to be updated outside of the normal app deployment cycle.
--
___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] Strips user access control of linked files

2016-11-28 Thread William Krick
There's a custom mechanism that creates security tokens.  I'm not really
sure how it works as this is a large application and the security framework
was developed by another group.

I'm guessing that conceptually, a proper solution to "secure" file links
would involve custom URLs that incorporate a security token string that are
only valid for the current user in the current session.





On Mon, Nov 28, 2016 at 4:30 PM, Rick Grashel  wrote:

> Hi William,
>
> How are your users logging in right now?  Through basic authentication or
> through a custom mechanism?
>
> -- Rick
>
> On Mon, Nov 28, 2016 at 2:23 PM, William Krick 
> wrote:
>
>> I'm working on a Stripes web application that provides links to tutorial
>> files.  The users have to log into the application.  The problem is that
>> the links to the tutorial files are accessible to anyone, whether they are
>> logged into the application or not.
>>
>> The links should only be accessible to logged-in users.
>>
>> Is there some standard way that this is done?
>>
>> Also, should the files be hosted outside of the web-accessible root
>> directory?
>>
>> I don't want to have to bundle the files inside the deployment war
>> because they may need to be updated outside of the normal app deployment
>> cycle.
>>
>> 
>> --
>>
>> ___
>> Stripes-users mailing list
>> Stripes-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>>
>
> 
> --
>
> ___
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
--
___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


[Stripes-users] stripes:options-map example?

2017-04-28 Thread William Krick
Is there an example somewhere that shows how to use the stripes:options-map
tag?

I'm trying to get it working with a Map object but not
having any luck.

I'm using this syntax...



The map is defined in my ActionBean like this...

private static final Map myMap = new HashMap();
static {
myMap.put("key1","Value 1");
myMap.put("key2","Value 2");
myMap.put("key3","Value 3");
}

public static Map getMyMap() {
return myMap;
}
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users