[Logo] Enterprise Client Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Messages posted by: mreich  XML
Profile for mreich -> Messages posted by mreich [744] Go to Page: Previous  1, 2, 3 ... 47 , 48, 49, 50 Next 
Author Message
Maybe you need to get values from an expression in your coding:
Code:
 public static String getValueFromExpression(String expression) {
   return (String) FacesContext.getCurrentInstance()
                        .getApplication().createValueBinding(expression)
                        .getValue(FacesContext.getCurrentInstance());
 }
 
When working with Hibernate (or another ORM) in combination with mySQL datetime (mySql Type) fields are mapped to timestamp(Java Type).
Now timestamp is a subclass of Date so you can use this directly as value in a t:calendarfield, the date is shown correctly, but if you change the value an error happens.
When working with a value map (HashMap<String, Object>) and you insert a timestamp, the calendarfield shows, as already mentioned before, the right date, but when you change the value, not a timestamp but a string value is set back. The cause is that t:calendarfield can not handle type timestamp, you have to convert to a date field. Please don't try to cast like (Date)timestampField, this won't work. You've to create a new Date field and set the timestamp values.

Example for putting the value in:
Code:
 Map<String, Object> values = new HashMap<String, Object>();
 Date date = null;
 Timestamp timestamp = entity.getTimestamp();
 if (timestamp!=null) {
   date =  new Date(timestamp.getTime());
 } 
 values.put("Date", date);
 


Example for receiving the value:
Code:
 Timestamp timestamp = null;
 Date date = (Date)values.get("Date");
 if (date!=null) {
   timestamp = new Timestamp(date.getTime());
 } 
 entity.setTimestamp(timestamp);
 

Hi Björn,

again thanx for your quick response!
In my case the root of evil was the the type Timestamp, although this class is a subclass of Date. So I tried to cast from Timestamp to Date and put this into my value map. In the map the date field was still a Timestamp Class, the calendarfield shows the right date, but when changing the value, it returned a String and not a Timestamp or Date class!
I now create a new Date field and set this field with the values from the Timestamp field (Date date = new Date(timestamp.getTime());)
Should I put this into the Snippet zone, maybe others also work with Hibernate/mySQL which usually use TimeStamp type for date handling?

regards
Markus
Hi,

I'm facing the same problems, I also use a <String, Object> Map for value binding, I but in a Timestamp object and when retrieving the entered value I got a String back.
Is there a simple workaround? I don't want to start converting with simple date format parsing, etc ..

regards
Markus
Hi,

in my grid i use the onEditColumnDetails functionality, now when I remove a column from the list, the grids header column gets removed but the cells doesn't change? I've added a screenshot the bean and the jsp.
By the way the log shows no error.

Markus
Thanx, now everything works
ok, I'll try

I zipped two managed beans incl. their JSP pages.
The userdetail is rowincluded in entitydetail
Hi Björn,

I set a label next to the button and it shows false, but the button is still visible, also no error in the log?
It's very strange, when I set the property fix to false:
protected String m_renderedButton = "false";
Aslo nothing happen, when I write "false" in the property field rendered in the Editor Tool the button disappears in the preview?!
When I use this property in the enabled property the button get's disabled?!
Very, very strange ...

Markus
Hi,

I've question about the rendered attribute, I make some buttons visibility depending on a certain bean property, I've created a String property renderdButtonXXX for each button.
The depending property is set in the beans constructor, after this but also in the constructor, the renderedButtonXXX is set to e.g. to false, but still shows up?!
Is there something special to consider?

Markus
perfect, all my questions were answered!
Hi,

I've a special question, as far as I know the Dispatcher extends a HashMap, which holds the managed beans by by class, so for each managed bean just one instance could exist in this map?
What happens, I've there are two rowincludes filled with the same kind of page, so referencing to the same managed bean properties? With replace content I can change the expression, but how the dispatcher manages this? Will there be a subdispatcher created?

regards
Markus
Hi Björn,

sorry for the delayed answer, but I get stucked with other things.
I tried to build a connection between the workpage and the rowincluded workpage, with helper methods in the WorkpageDispatchedBean implemtation:

public UserDetailUI getUserDetailUI() {
return (UserDetailUI) getOwningDispatcher().getDispatchedBean(
UserDetailUI.class);
}

public EntityDetailUI getEntityDetailUI() {
return (EntityDetailUI) getOwningDispatcher().getDispatchedBean(
EntityDetailUI.class);
}

Now I create an instance of the Workpage(EntityDetailUI), in the constructor I call:

public EntityDetailUI(IWorkpageDispatcher dispatcher) {
super(dispatcher);
userDetailUI = getUserDetailUI();
}

userDetailUI is declared as private

When getUserDetailUI is called the constructor of UserDetailUI is called:
public UserDetailUI(IWorkpageDispatcher dispatcher) {
super(dispatcher);
// get wrapping entity detail UI bean
entityDetailUI = getEntityDetailUI();
}

Now the problem occurs when calling the statement getEntityDetailUI(), the constructor of EntityDetailUI is called again, this one calls the UserDetailUI and so on, till game over?!

It's a bit complicated to explain, sorry for that ...

Markus



maybe it makes sense to install a kind of Code Snippets area in the forum?

Markus
Hi,

I use NSIS, there is a great plugin for eclipse.

Markus
ok, setting the Cookie will work like this?

HttpServletResponse httpServletResponse = (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
Cookie cookie = new Cookie("myCookie", "cookieID");
cookie.setID("123456");
httpServletResponse.addCookie(cookie);
 
Profile for mreich -> Messages posted by mreich [744] Go to Page: Previous  1, 2, 3 ... 47 , 48, 49, 50 Next 
Go to:   
Powered by JForum 2.1.6 © JForum Team