问题
I have a problem regarding JfreeChart.createBufferedImage(width,Height,info) i am creating a jFreechart in java and showing it in JSF page like this JfreeChart.createBufferedImage(width,Height,info)
Right now i am passing width and height as hardcoded attributes but i want the width and height should dynamically set accoding the cleint screen resolution in JSF page.
Is there any way around to do it ?
回答1:
There isn't a straight forward way. If you aren't familiar with the JSF lifecycle I would check it out (balusc made a great article), but essentially the process would be this:
- Initial response is sent to client with javascript
- Javascript gets screen size and inserts them in hidden fields and submits a form
- Second response is your current page except with the numbers from the hidden fields.
You likely will want an ajax enabled framework that will let you poll so that when the window changes your chart can be regenerate appropriately.
来源:https://stackoverflow.com/questions/5727925/dynamically-setting-width-and-height-according-to-client-screen-resolution-in-jf