Received: by 10.50.170.72 with SMTP id ak8mr5158655igc.0.1349651778607; Sun, 07 Oct 2012 16:16:18 -0700 (PDT) X-BeenThere: liftweb@googlegroups.com Received: by 10.43.7.131 with SMTP id oo3ls11876542icb.8.gmail; Sun, 07 Oct 2012 16:16:13 -0700 (PDT) Received: by 10.42.70.131 with SMTP id f3mr57387icj.4.1349651773566; Sun, 07 Oct 2012 16:16:13 -0700 (PDT) Received: by 10.42.70.131 with SMTP id f3mr57386icj.4.1349651773546; Sun, 07 Oct 2012 16:16:13 -0700 (PDT) Return-Path: Received: from mail-ie0-f170.google.com (mail-ie0-f170.google.com [209.85.223.170]) by gmr-mx.google.com with ESMTPS id us14si1009377igb.3.2012.10.07.16.16.13 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 07 Oct 2012 16:16:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gaoy...@gmail.com designates 209.85.223.170 as permitted sender) client-ip=209.85.223.170; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of gaoy...@gmail.com designates 209.85.223.170 as permitted sender) smtp.mail=gaoy...@gmail.com; dkim=pass header...@gmail.com Received: by mail-ie0-f170.google.com with SMTP id c12so9234503ieb.29 for ; Sun, 07 Oct 2012 16:16:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:mime-version:content-type:subject:date:in-reply-to:to :references:message-id:x-mailer; bh=ky/7ViwCPo6o3FSgGUGZZqrgGphantd+NZ9fRiLwC7c=; b=lsapYpf3H/gfJ55L/VIBGyx6Vmq2o5jPJeP/LBkr26uiwS6ITyXKgrS6qxZPBROfxE zk9+Hecy+y5LHW2SNUZ4V50BNPeA0QSpS45V0YwXAh4rq7QX9kPLAkexINaAFfYblJ5P KoQgUyQWxu8QOaP50P8kNW3x890A6Qjy0vaEq+W/DlC5DeAr2Qmk3zbMpXl1lsIRTd9C QsPQzIoJN0jjNlGUBne0QvbCv/m2lulp81FvgECbcdQ55wPHg5ox/MBCU0HkTYIy1U+B tysfA5ww+cc3I8k1Z9znl/bmZMxnV6I5VY0w5legu9yRwJ9DExV3/K2SmY4d4GcgceD9 p3hw== Received: by 10.50.185.200 with SMTP id fe8mr6534425igc.35.1349651773213; Sun, 07 Oct 2012 16:16:13 -0700 (PDT) Return-Path: Received: from [192.168.1.105] (173-25-203-61.client.mchsi.com. [173.25.203.61]) by mx.google.com with ESMTPS id gw10sm5683173igb.17.2012.10.07.16.16.11 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 07 Oct 2012 16:16:12 -0700 (PDT) From: Chenguang He Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: multipart/alternative; boundary="Apple-Mail=_12F51ABE-3091-4881-BDC0-1CFF6A1FCA2A" Subject: Re: [Lift] Lift comet do not render when the first time of loading page Date: Sun, 7 Oct 2012 18:16:09 -0500 In-Reply-To: To: liftweb@googlegroups.com References: <0EA383F4-F744-4B5B-B2FE-BCD69477E...@gmail.com> Message-Id: X-Mailer: Apple Mail (2.1283) --Apple-Mail=_12F51ABE-3091-4881-BDC0-1CFF6A1FCA2A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=GB2312 Hey David, I can not change the comet to state-based update. Is there any way that = use time-based update to make the page work in first time loading ? Thank you=20 Chenguang He On Oct 7, 2012, at 5:33 PM, David Pollak wrote: > You should not use a timed update. You should update the CometActor on = state change on the server (time is not state change) > If you post a reproducible example, we can help you. >=20 > On Sun, Oct 7, 2012 at 3:24 PM, Chenguang He = wrote: > Hey guys, > I have a page, that want to render every 10sec. i use = ActorPing.schedule, which same to the demo in lift website. > However, i found that, when use load page in the first cycle of 10sec, = the page will not be rendered by comet. And, everything work fine, = after 10sec. >=20 > Here is the code: >=20 >=20 >=20 > package code.comet >=20 >=20 > class hotjobs extends CometActor { > private var jobs:List[Jobs] =3D Nil >=20 > def render =3D "#hot" #> {jobs.flatMap(jobsExtrator _)}
>=20 > def jobsExtrator(j:Jobs):NodeSeq=3D > > {modifyDate(j.createdAt.toString())} > {j.title} > {j.companyName} > {j.location} > > >=20 > def modifyDate(s:String):String=3D{ > val b =3D s.split(" ") > return b(1)+"-"+b(2)+"-"+b(3) > } >=20 >=20 > ActorPing.schedule(this, Message, 10000L) >=20 > override def lowPriority =3D { > case Message =3D> { > reRender() > jobs =3D Jobs.findJobsinTop > ActorPing.schedule(this, Message, 10000L) > } > } > } > case object Message >=20 > Chenguang He >=20 >=20 >=20 >=20 > -- > -- > Lift, the simply functional web framework: http://liftweb.net > Code: http://github.com/lift > Discussion: http://groups.google.com/group/liftweb > Stuck? Help us help you: = https://www.assembla.com/wiki/show/liftweb/Posting_example_code >=20 >=20 >=20 >=20 >=20 >=20 > --=20 > Telegram, Simply Beautiful CMS https://telegr.am > Lift, the simply functional web framework http://liftweb.net > Follow me: http://twitter.com/dpp > Blog: http://goodstuff.im >=20 >=20 >=20 > --=20 > --=20 > Lift, the simply functional web framework: http://liftweb.net > Code: http://github.com/lift > Discussion: http://groups.google.com/group/liftweb > Stuck? Help us help you: = https://www.assembla.com/wiki/show/liftweb/Posting_example_code > =20 > =20 > =20 --Apple-Mail=_12F51ABE-3091-4881-BDC0-1CFF6A1FCA2A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=GB2312 Hey = David,
I can not change the comet to state-based update. Is there = any way that use time-based update to make the page work in first time = loading ?

Thank you 
Chenguang = He




On Oct 7, 2012, at 5:33 PM, David Pollak wrote:

  1. You = should not use a timed update. You should update the CometActor on state = change on the server (time is not state change)
  2. If you post = a reproducible example, we can help you.

On Sun, Oct 7, 2012 at 3:24 PM, Chenguang He <gaoy...@gmail.com> wrote:
Hey guys,
I have a page, that want to render every 10sec. i use = ActorPing.schedule, which same to the demo in lift website.
However, i found that, when use load page in the first cycle of 10sec, = the page will not be rendered  by comet. And, everything work fine, = after 10sec.

Here is the code:



package code.comet


class hotjobs  extends CometActor {
  private var jobs:List[Jobs] =3D Nil

  def render =3D "#hot" #> <table class=3D"table = table-striped">{jobs.flatMap(jobsExtrator _)}</table>

  def jobsExtrator(j:Jobs):NodeSeq=3D
    <tr>
      = <td>{modifyDate(j.createdAt.toString())}</td>
      <td>{j.title}</td>
      <td>{j.companyName}</td>
      <td>{j.location}</td>
      <td style=3D"text-align: right;"><button = type=3D"button" datatoggle=3D"button" = onClick=3D{JsCmds.RedirectTo("/jobDetail.html?jobid=3D"+j.id)}>=C1=A2=BC=B4=C9=EA=C7=EB</button><= ;/td>
    </tr>

  def modifyDate(s:String):String=3D{
    val b =3D s.split(" ")
    return  b(1)+"-"+b(2)+"-"+b(3)
  }


  ActorPing.schedule(this, Message, 10000L)

  override def lowPriority =3D {
    case Message =3D> {
      reRender()
      jobs =3D Jobs.findJobsinTop
      ActorPing.schedule(this, Message, 10000L)
    }
  }
}
case object Message

Chenguang He




--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_examp= le_code






-- =
Telegram, Simply Beautiful CMS https://telegr.am
Lift, the simply functional = web framework http://liftweb.net



--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/g= roup/liftweb
Stuck? Help us help you: h= ttps://www.assembla.com/wiki/show/liftweb/Posting_example_code
 
 
 

= --Apple-Mail=_12F51ABE-3091-4881-BDC0-1CFF6A1FCA2A--