I get back to you as soon as I can... I a bit busy rigth now. Richard
On Thu, Mar 7, 2013 at 12:27 PM, Riccardo C <[email protected]> wrote: > *index.html* > bla bla bla... > <div class="span12"> > {{=LOAD('default','maintxt.load',target='chat')}} > <div id="chat"></div> > bla bla bla... > > maintxt.load > {{=form}} > > {{for msg in msgList:}} > > <b>{{=msg.body}} </b> > <a id="link{{=msg.id}}" > onclick="web2py_component('{{=URL('replies.load',args=[str(msg.id > )])}}','target{{=str(msg.id)}}');">show thread and reply</a><br> > > <div id="target{{=msg.id}}"></div> > > {{pass}} > > replies.load > {{for msg in replyList:}} > > {{=LI(I(msg.body+' @ '+str(msg.submitdate), _class='risposta'))}} > > {{pass}} > > {{=form2}} > > > CONTROLLER > > @auth.requires_login() > def maintxt(): > db.shortmsg.authorId.default = auth.user.id > db.shortmsg.authorName.default =auth.user.first_name > > form = SQLFORM(db.shortmsg) > if form.process(session,formname='form_one').accepted: > redirect('welcome') > > msgList = db(db.shortmsg.refSms==-1).select(db.shortmsg.ALL, > orderby=db.shortmsg.submitdate) > > return dict(form=form, msgList = msgList) > > @auth.requires_login() > def replies(): > TableSMS = db.shortmsg > TableSMS.refSms.default = request.args(0) > TableSMS.authorId.default = auth.user.id > TableSMS.authorName.default =auth.user.first_name > > form2 = SQLFORM(TableSMS) > if form2.process(formname='form_two').accepted: > pass > > replyList = db( (TableSMS.refSms==request.args(0)) & > (db.shortmsg.submitdate!=None)).select(db.shortmsg.body, > db.shortmsg.submitdate); > > > return dict(form2=form2, replyList=replyList) > > MODEL > db.define_table('shortmsg', > Field('body','text', requires=IS_NOT_EMPTY()), > Field('submitdate','datetime', default = request.now, readable= False, > writable=False), > Field('refSms','integer',default=-1, readable = False, writable = > False), > Field('authorName','string',default='Anonymous', > requires=IS_NOT_EMPTY(), readable = False, writable = False), > Field('authorId','integer', requires=IS_NOT_EMPTY(), readable = False, > writable = False)) > > > Il giorno giovedì 7 marzo 2013 13:35:23 UTC, Richard ha scritto: >> >> Could you show more code, controller for both component and the views >> associated >> >> Richard >> >> >> On Wed, Mar 6, 2013 at 4:49 PM, Riccardo C <[email protected]> wrote: >> >>> Thank you very much, that is exactly what I needed... I didn't know >>> components! >>> >>> I have component related question know. >>> I have a first component that generate the first form (form1) based on >>> tableA and a second component that list all the post and a second form >>> (form2) generate on the same tableA. >>> Now in the firstcomponent.load file, I've included the second >>> component...something along these lines: >>> {{=form1}} >>> load('controller','**functionsecondcomponent','two'**) >>> <div id="two"><div> >>> And the i call this component in the main page "index.html". >>> >>> Everything is rendered correctly: form1 and form2 appears correctly but >>> do not work has I was expected. If I submit through form2, the content of >>> the post is correctly recorder in the tableA, if I try to use form1 it >>> doesn't work. When I press the submit button the index.html is refreshed >>> but without any effect on tableA. Any suggestions? >>> >>> Thanks a lot. >>> >>> Riccardo >>> >>> >>> >>> Il giorno giovedì 28 febbraio 2013 21:47:46 UTC, Richard ha scritto: >>>> >>>> I don't understand your problem very well... Do you have a problem >>>> refreshing the post? As far as I understand, you have write your own ajax >>>> call to update the stuff in your page... >>>> >>>> You could try someting like that in your view (read about web2py LOAD() >>>> and component) : >>>> >>>> # Your insert form >>>> {{=form}} >>>> >>>> {{=LOAD(..., yourFunctionThatListThePost, ...)}} >>>> >>>> You can then in you main function/page calling a refresh of you >>>> component like that : >>>> >>>> if form.accepts(request.vars, session): >>>> ... >>>> response.js="web2py_component(****'%s','two');" % >>>> URL('yourController','**yourFunc**tionThatListThePost', >>>> args='ifRequired') >>>> >>>> >>>> About web2py_component : >>>> >>>> https://groups.google.com/d/**ms**g/web2py/RSDIwe8BDxA/**chcikCg0R**pkJ<https://groups.google.com/d/msg/web2py/RSDIwe8BDxA/chcikCg0RpkJ> >>>> >>>> >>>> Hope it helps! >>>> >>>> Richard >>>> >>>> >>>> On Thu, Feb 28, 2013 at 1:30 PM, Riccardo C <[email protected]>wrote: >>>> >>>>> Good evening, >>>>> >>>>> I am trying to do a very simple 'twitter like' message board with the >>>>> simple aim to learn to program and get used to web2py framework. >>>>> The problem is that I decided (I don't know if it is the best choice) >>>>> to use one single table for both the new messages and the answers. >>>>> >>>>> What I do is showing on top of the index.html page, the form to >>>>> introduce new messages and below all the new messages (without the >>>>> answers) >>>>> followed by a link associated with a ajax callback (replies.html). >>>>> This second function return to me all, if any, messages associated to >>>>> 'main text' AND a form that is generated from the same table with the >>>>> refSms field set (and not showed) to the id of the main message. >>>>> >>>>> What happens? when I reply to a message and I click on submit the page >>>>> refresh without insert in the db the new row. Can someone help me to * >>>>> understand* what is wrong? >>>>> >>>>> Thanks >>>>> >>>>> -- >>>>> >>>>> --- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "web2py-users" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to web2py+un...@**googlegroups.com. >>>>> >>>>> For more options, visit >>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out> >>>>> . >>>>> >>>>> >>>>> >>>> >>>> -- >>> >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "web2py-users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to web2py+un...@**googlegroups.com. >>> For more options, visit >>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>> . >>> >>> >>> >> >> -- > > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

