4 Replies - 2738 Views - Last Post: 26 March 2013 - 08:23 AM

#1 aks29921  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 84
  • View blog
  • Posts: 230
  • Joined: 24-August 09

Java Code in XHTML in JSF 2

Posted 05 December 2012 - 05:44 AM

In JSF 1.2, I used to do the following in my jsp page
<%
 MyClass myClassObj = (MyClass) session.getAttribute("myClass");

  if (myClassObj == null)
  {
    myClassObj = new MyClass();
    myClassObj.setType("1");
    session.setAttribute("myClass", myClassObj);
  }
%>



However, now I am working in JSF 2.0 where xhtml pages are used instead of jsp.
So scriptlets can't be used.

Is there some way in which this can still be achieved in xhtml?

Is This A Good Question/Topic? 0
  • +

Replies To: Java Code in XHTML in JSF 2

#2 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 850
  • View blog
  • Posts: 2,594
  • Joined: 29-July 11

Re: Java Code in XHTML in JSF 2

Posted 05 December 2012 - 08:16 AM

You're probably better off posting this in the JavaEE forum.
Was This Post Helpful? 0
  • +
  • -

#3 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10648
  • View blog
  • Posts: 39,544
  • Joined: 27-December 08

Re: Java Code in XHTML in JSF 2

Posted 05 December 2012 - 08:32 AM

Moved to Java EE.
Was This Post Helpful? 0
  • +
  • -

#4 blufab  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 19-January 11

Re: Java Code in XHTML in JSF 2

Posted 26 March 2013 - 08:17 AM

Code such as that are best moved to the backing bean. The only functional code per say should be mechanism controlling your layout.
Was This Post Helpful? 0
  • +
  • -

#5 blufab  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 19-January 11

Re: Java Code in XHTML in JSF 2

Posted 26 March 2013 - 08:23 AM

Maybe try something like
<c:set var="myClass.type" value="1" />


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1