Re: Hibernate problem with OGNL

2013-03-27 Thread Steve Higham

On 27/03/2013 10:42, Markus Demetz wrote:

Hi,


I have situations, where the getId() method of my model class returns 
null

when navigating through OGNL e.g. when
calling .


Have you tried  or 

No luck :-(
I also tried with JSTL now without success.
It's very strange, since sometimes it works and then it reappears again.
I'll ask at the hibernate forum.

Regards,
Markus

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org


I've seen this behavior on newly created instances. Hibernate doesn't 
know the ID until the object is persisted to the DB. Hibernate tries to 
delay this as long as possible to minimise DB writes. You would have 
thought a request for the ID would force a DB write but Hibernate 
doesn't seem to implement this behavior. If you want the ID you need to 
force the DB write first.


Steve

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: How to pretty print HTML from Struts

2012-09-30 Thread Steve Higham
Yes - I've got some complex tags and the resultant HTML has loads of
redundant whitespace in all the wrong places. Trying to compare with
original mock-ups takes for ever.

I like doing this with a filter because it's easy to remove if I'm having
problems later. I've just got it working and it's doing what I want. I
appreciate it may cause problems later...

The correct config is: -


  JTidyFilter
  *.action

 

  StrutsFilter
  /*


It was just the ordering of the filters that was causing problems.

Is there a better way of tidying up the HTML being emitted from a Struts
View?

Kind Regards,

Steve


-Original Message-
From: Dave Newton [mailto:davelnew...@gmail.com] 
Sent: 30 September 2012 18:05
To: Struts Users Mailing List
Subject: Re: How to pretty print HTML from Struts

Ugh. IMO relying on textual representation of a DOM is fragile and broken,
especially if you're unable to ignore whitespace-is there a reason you're
doing it like this?

Dave

(pardon brevity, typos, and top-quoting; on cell) On Sep 30, 2012 12:22 PM,
"Steve Higham"  wrote:

> My Struts Views are made up of JSP and Tiles and the resulting HTML is 
> untidy to say the least. This causes problems when I try to compare it 
> with HTML mock-ups. To solve this I'm trying to use the JTidy library 
> to pretty print the HTML output to the browser.
>
>
>
> I'm using the JTidyFilter configured as follows: -
>
>
>
>  
>
>StrutsFilter
>
>/*
>
>  
>
>
>
>  
>
>JTidyFilter
>
>/*
>
>  
>
>
>
> This seems to be failing because the Struts Filter Dispatchers only 
> pass the request down the Filter Chain if it is not a Struts Request 
> (e.g.
> *.action).
> Therefore this config will try to pretty-print *.css, *.js, *.img etc. 
> but completely ignores the outputs of my actions.
>
>
>
> Does anyone know a sensible way of pretty printing the Struts HTML 
> output to the browser?
>
>
>
> Many Thanks,
>
>
>
> Steve
>
>
>
> Steve Higham
>
>
>
>


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



How to pretty print HTML from Struts

2012-09-30 Thread Steve Higham
My Struts Views are made up of JSP and Tiles and the resulting HTML is
untidy to say the least. This causes problems when I try to compare it with
HTML mock-ups. To solve this I'm trying to use the JTidy library to pretty
print the HTML output to the browser.

 

I'm using the JTidyFilter configured as follows: -

 

 

   StrutsFilter

   /*

 

  

 

   JTidyFilter

   /*

 

 

This seems to be failing because the Struts Filter Dispatchers only pass the
request down the Filter Chain if it is not a Struts Request (e.g. *.action).
Therefore this config will try to pretty-print *.css, *.js, *.img etc. but
completely ignores the outputs of my actions.

 

Does anyone know a sensible way of pretty printing the Struts HTML output to
the browser?

 

Many Thanks,

 

Steve

 

Steve Higham

 



RE: Struts2 : XML based View

2012-07-09 Thread Steve Higham
Hi,

I have projects that include JS (and jquery) in the HTML pages they output.
It's then up to you to construct your jquery widgets when the document
loads. Is this what you are looking for...

Cheers,

Steve

-Original Message-
From: Anupam Bakshi [mailto:baks...@yahoo.com] 
Sent: 09 July 2012 09:02
To: user@struts.apache.org
Subject: Struts2 : XML based View

Hello,
  In my Struts2 action, I have a database returning XML data as a stream
that is transformed using XSLT2.
  This is fine, but I need the result to also have jquery tabs and submit
buttons.
 
  Is there any way to achieve this on-the-fly generation and insertion of
these struts2 and struts2-jquery tags?

Thanks,
Anupam


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: Does the StrutsTestCase test filters defined in web.xml?

2012-05-14 Thread Steve Higham
Hi Miguel,

I haven't used the StrutsSpringTestCase however I have made use of the 
StrutsTestCase.

This only tests the interceptor stack / Action / Result. There is no web server 
involved and no attempt to render the resulting page. Therefore I would be 
surprised if anything from web.xml is called.

You could try looking at Apache Cactus or Apache HttpClient to test this 
behaviour? Alternatively if you generate the file within Struts then the 
StrutsTestCase will suffice. I've generated exports from Struts this way.

Cheers,

Steve

-Original Message-
From: Miguel Almeida [mailto:mig...@almeida.at] 
Sent: 14 May 2012 10:16
To: user@struts.apache.org
Subject: Does the StrutsTestCase test filters defined in web.xml?

Dear all,

I am using StrutsSpringTestCase (which extends StrutsTestCase) to perform some 
acceptance tests (under the skin). I am also using Displaytag 
(www.displaytag.org/1.2/ ) to build some tables in the view.
This tag supports excel/pdf export, which uses a filter you configure in 
web.xml [1]

The way the filter works is, in short: a (odd looking, numerical) parameter is 
added to the request. The filter checks for the existence of that parameter 
and, if it exists, creates the pdf/excel. 

I want to test the creation of this file (and its contents). However, when I 
debug the StrutsSpringTestCase test with a breakpoint on that filter it does 
not stop there, so my questions are:

1) Does the StrutsTestCase not pass through other filters in your web.xml, and 
only goes through the struts filter?
2) If so, is there anything else in the struts tests that could help me out? 
How do you suggest I perform this test?
 
Thank you,

Miguel Almeida



[1]- see http://www.displaytag.org/1.2/export_filter.html 


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: Struts 2 Rest Showcase Example : Issue in understanding code

2012-05-01 Thread Steve Higham
Hi Srineel,

I would recommend purchasing a copy of Struts 2 In Action published by
Manning. You're not going to pick Struts up by browsing through a couple of
examples.

Cheers,

Steve

-Original Message-
From: Srineel Mazumdar [mailto:smaz19...@gmail.com] 
Sent: 01 May 2012 09:34
To: Struts Users Mailing List
Subject: Struts 2 Rest Showcase Example : Issue in understanding code

Hi,

I am new to Struts 2 and hence I am downloading the the samples from Apache
site. Struts 2 Rest Showcase Example is the one I am refering to.

I have the follwoing questions :

1) What is meant by :
@Results({
@Result(name="success", type="redirectAction", params = {"actionName" ,
"orders"})
})

in OrdersController.java ?

2) Meaning of the entries in struts.xml:










3) a) How the code "understands and decides" which method to call in
OrdersController.java  ?
b) We have *"return "editNew";" *etc return types . Where exactly are
these being used and how does the applciation decide which page to navigate
based on the return types ?

Regards

Srrineel Mazumdar


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: StrutsTestCase, jUnit and file upload

2012-04-26 Thread Steve Higham
Thanks to Chris, Gabriel for your comments.

I finally got this to work yesterday. A neat solution probably requires
refactoring StrutsTestCase and deriving a new class
(StrutsMultipartTestCase) from it. In the meantime the following changes
will work subject to a couple of limitations: -

This only supports upload of a single file - although fairly simple to
extend for multiple files.
I've use Mockito for a couple of mocks
It's not very clean :-(

First you need spring-web-x.y.z.jar on your classpath. This comes with the
junit plugin.

Your test class needs the following override. This is a cut & paste job from
StrutsTestCase except for the request creation line.

/**
 * We need to override this method so we can use class 
 * MockMultipartHttpServletRequest for the request.
 */
@Override
protected void initServletMockObjects() 
{
  servletContext = new MockServletContext(resourceLoader);
  response = new MockHttpServletResponse();
  request = new MockMultipartHttpServletRequest();
  pageContext = new MockPageContext(servletContext, request, response);
}

We now need a new version of getActionProxy with additional parameters as
follows: -

/**
 * We need our own version to handle the file uploading
 * @param uri  struts action uri
 * @param contentType  mime content type
 * @param filename  name reported to action
 * @param file  uploaded file
 * @return  ActionProxy
 */
protected ActionProxy 
getActionProxy (String uri, String contentType, String filename, File file)
{
// Create the proxy
ActionProxy result = super.getActionProxy (uri);

// Not part of upload but I think required for SessionAware
ActionContext context = result.getInvocation ().getInvocationContext
();
if (context.getSession () == null)
{
context.setSession (new HashMap ());
}

// Wrap the request in a MultiPartRequestWrapper
MultiPartRequest mpr = 
createMultiPartRequest (contentType, filename,
file);
MultiPartRequestWrapper wrapper = 
new MultiPartRequestWrapper (mpr, request, null);
ServletActionContext.setRequest (wrapper);

return result;
}

protected MultiPartRequest 
createMultiPartRequest (String contentType, String fileName, File file)
{
MultiPartRequest result = Mockito.mock (MultiPartRequest.class);
Vector fileParameterNames = new Vector ();
fileParameterNames.add (PROP_NAME);
Enumeration enumFpn = fileParameterNames.elements ();
Mockito.when (result.getFileParameterNames ()).thenReturn (enumFpn);
String [] contentTypes = new String [1];
contentTypes [0] = contentType;
Mockito.when (result.getContentType (PROP_NAME)).thenReturn
(contentTypes);
String [] fileNames = new String [1];
fileNames [0] = fileName;
Mockito.when (result.getFileNames (PROP_NAME)).thenReturn
(fileNames);
File [] files = new File [1];
files [0] = file;
Mockito.when (result.getFile (PROP_NAME)).thenReturn (files);

return result;
}

private static final String PROP_NAME = "propertyName";

This assumes that your upload action has methods setPropertyName (File),
setPropertyNameContentType (String), setPropertyNameFileName (String).

The @Test methods now include the following: -

File uploadedFile = new File ("path to test file");
ActionProxy proxy = getActionProxy ("uri", "content type e.g. text/csv",
file.getName (), file);
assertTrue (proxy.execute ().equals ("expected action result");

Note that the calls to the action are generated internally. You don't need
any request.setParameter (...) calls.

Cheers,

Steve

-Original Message-
From: Steve Higham [mailto:st...@sjlt.co.uk] 
Sent: 25 April 2012 11:08
To: 'Struts Users Mailing List'
Subject: StrutsTestCase, jUnit and file upload

I'm currently using StrutsTestCase and jUnit to component test my Actions
within the Struts context using a Mockito mock as my Model.

 

This is working fine. I can call request.setParamater ("paramName",
"paramValue") from the test class and, when executed, Struts will call the
corresponding setParamName ("paramValue") on my Action.

 

However I now wish to test "file upload" Actions. In normal use the
FileUploadInterceptor will call setUploadedFile (java.io.File file) on the
action. However I can't see any methods on the StrutsTestCase request object
which will prepare the request with an uploaded file. Has anyone got this to
work?

 

Steve Higham

 



-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



StrutsTestCase, jUnit and file upload

2012-04-25 Thread Steve Higham
I'm currently using StrutsTestCase and jUnit to component test my Actions
within the Struts context using a Mockito mock as my Model.

 

This is working fine. I can call request.setParamater ("paramName",
"paramValue") from the test class and, when executed, Struts will call the
corresponding setParamName ("paramValue") on my Action.

 

However I now wish to test "file upload" Actions. In normal use the
FileUploadInterceptor will call setUploadedFile (java.io.File file) on the
action. However I can't see any methods on the StrutsTestCase request object
which will prepare the request with an uploaded file. Has anyone got this to
work?

 

Steve Higham

 



RE: event On struts

2012-04-22 Thread Steve Higham
Hi,

Struts is very different to .NET. The underlying technologies are used in a
very open fashion. The good thing is that this means you can do pretty much
anything you like. The downside is that you need to understand the
underlying technologies and do some legwork.

As suggested you can use embed JavaScript in the HTML generated by Struts
from JSP or a similar technology. You need to create this JavaScript.
However you can use whatever your favourite JS library is to simplify
things. I've got some code using JQuery that parses the HTML and adds
JavaScript extensions to standard HTML controls. This provides the basic
mechanism to react to user selection etc.

If you want to, you could then make something like a JSON call back to the
Server. Struts can react to this using appropriate Result types. I think
there's a plug-in somewhere that helps this process but I haven't used it.

Enjoy...

Steve

-Original Message-
From: loinheart [mailto:shah_khan_1...@hotmail.com] 
Sent: 21 April 2012 17:43
To: user@struts.apache.org
Subject: event On struts

Hey h

Im a new in struts so please kindly tell me how to create event on struts
control like a dot net Control ?

I want to perform a  selected index action on dropedown so please any tell
me how to perform to this ..?

--
View this message in context:
http://struts.1045723.n5.nabble.com/event-On-struts-tp5656488p5656488.html
Sent from the Struts - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: [Struts2] Upgrading a Struts2 Application that uses Tiles2.

2012-01-24 Thread Steve Higham
Hi Hernán,

I'm running Tiles 2.2.2 on Struts 2.2.3 and it's working fine. I get a bunch
of warnings when the app loads including 

WARN  [TilesContainerFactory] DEPRECATION WARNING! You are using
parameter-based initialization, that is no longer supported! Please see
docs: http://tiles.apache.org/framework/tutorial/configuration.html

Therefore I'm not sure this will be supported going forward. I guess this
will continue until the Struts2-tiles-plugin gets updated. However it seems
to work fine for Tiles 2.2.2

Kind Regards,

Steve

-Original Message-
From: Hernán [mailto:heam...@gmail.com] 
Sent: 23 January 2012 21:00
To: Struts Users Mailing List
Subject: [Struts2] Upgrading a Struts2 Application that uses Tiles2.

I have developed a web application that uses tiles2, the question is: the
last version of struts2 (2.3.1.2) is compatible with newer versions of
tiles? I mean not only Tiles 2.0.6 but higher versions, for example Tiles
2.2.2. Thank you very much

--
Hernán


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org