C4: A way to design the system architecture

20 09 2014

Context -> Container -> Component -> Class is an approach to design system architecture. The first three are definetely the responsibility of an architect, but the class diagram is mostly dependant on developers’ approach.

I like this model, because I used its concepts and it helped me much on an early stages of system design.

Clear and informative infographic explains the concept well:



Refresh JSF page programmatically from JavaBean

4 08 2012

When business logic in JavaBean decides that forced jsf page refresh is needed, it can be done from logic’s level. Add this code to your logic (prefereably put it in some refresh() method):

FacesContext context = FacesContext.getCurrentInstance();
String viewId = context.getViewRoot().getViewId();
ViewHandler handler = context.getApplication().getViewHandler();
UIViewRoot root = handler.createView(context, viewId);

Browsers may have cache enabled, so some cached elements may not be refreshed. If this is your case, you should also add header to Http response, that will force browser not to use cache:

response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);

Cached elements were not my problem, so the second snippet is not tested by me. For more info, please see following sources: OTN Discussion Forum, Refresh current JSF page and caching on StackOverflow.

Note: page refresh done that way means sending Http Response – one Http Request can have only one Http Response. You can’t use this code if you have already sent your response earlier for this particular Http Request.

For example – while performing file download. The file download data is sent in Http Response, so unfortunately there is no way to refresh page programmaticaly. Probably Ajax refresh could help you, if just some of the components should be rerendered. This problem is described in threads: StackOverflow thread 1Coderanch question, another Coderanch problem, refresh after response is commited, and the last one Coderanch – so.. just impossible…


.. so maybe better to use this JavaScript delayed reload – give it a try!

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!

%d bloggers like this: