Changing language but a little bit easier than "forms-example"

classic Classic list List threaded Threaded
35 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Changing language but a little bit easier than "forms-example"

fl.schmitt(ops-users)
hi Masen,

> first thing: how many mails can I write before you'll kill me?(kiddin=))

don't worry about it :-)

Another tip: the Shopping cart example has a complete solution how to read and
write into and from the session scope. MAybe this is helpful, too...

> If I have a xform that has an instance: (...)

looks ok for me

> 1) How can I store that value (just to understand that whole
> scope-thing) into a session scope?

you will have to submit that instance to a pipeline (below i will explain how).
The submission looks basically valid, too.

> 2) My submission works, but the xpl file doesn´t...

ok, so let's work on the XPL file and how to access it. There are two values
that have to correspond to each other: the action uri of the submission element
in your xforms: action="write-lang" , and the path-info attribute in the
page-flow entry for the XPL. The path-info doesn't point to a real path element
(directory or file) in the file system - it's a kind of identifier which
page-flow entry should be activated when a submission is issued. It maps the
available pages ant XPL to URIs.

In the Shopping Cart example, we have a "add.xpl" XPL file. To make it
accessible, there's a page flow entry:

<page *path-info="/xforms-cart/add"* >
     <action action="add.xpl"/>
</page>

To invoke it, the view.xhtml contains a corresponding submission:
<xforms:submission id="add" *action="/xforms-cart/add"* ref="instance('item')"
method="post" replace="none"/>

What matters here is the action attribute containing an absolute URI. This way,
the xforms engine knows that the submitted instance should be forwarded to the
XPL specified.

In this special case, the add.xpl doesn't simply write the submitted data into
the scope. It has two processors. The first reads the actual content from the
scope (generator, the result is a XML instance); the second one aggregates the
result of the first processor with the new item to add, that was submitted from
the view.xhtml, and writes this expanded XML instance back to the scope.

In your case, you don't need the first step (read the scope), because the old
language selection should be overwritten. So, the following should be suffient:

<p:config
         xmlns:oxf="http://www.orbeon.com/oxf/processors"
         xmlns:p="http://www.orbeon.com/oxf/pipeline">
     <p:param type="input" name="instance"/>
     <p:processor name="oxf:scope-serializer">
         <p:input name="config">
             <config>
                 <key>language</key>
                 <scope>session</scope>
                 <session-scope>application</session-scope>
             </config>
         </p:input>
         <p:input name="data" href="#instance"/>
     </p:processor>
</p:config>


To read the data from the scope, you could take the get.xpl file almost without
changes, only the "key" element in the scope-generator config must match the key
  used in the scope-serializer. Above, i changed it to "language".

If you get this working, you can make xml data persistent in the session scope,
and read it again. The next step would be to change the "get.xpl" pipeline so
that it doesn't return the language but the corresponding labels file.

HTH
florian


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Changing language but a little bit easier than "forms-example"

masjab-2
Jeeeez! It´s working!!!!!!!! =) =)!!!!!! almost....
Ok, here is what it looks like right now:

<xforms:model id="resources-model"
              xmlns:xs="http://www.w3.org/2001/XMLSchema"
              xmlns:xforms="http://www.w3.org/2002/xforms"
              xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
              xmlns:ev="http://www.w3.org/2001/xml-events">

    

    <xforms:action ev:event="xforms-ready"><xforms:send submission="get-lang"/></xforms:action>

   

    <xforms:instance id="language-instance">
        <language xmlns="">de</language>
    </xforms:instance>

           

    <xforms:instance id="resources-instance" src="oxf:/apps/2604/homepage/common/res-en.xml"
    xxforms:readonly="false"/>

    

    <xforms:instance id="testInstance">
        <language xmlns="">es</language>
        </xforms:instance>

    

    <xforms:submission id="add-lang" action="/2604/add" ref="instance('language-instance')" method="post"  replace="none" />
    <xforms:submission id="get-lang" action="/2604/get" method="get" serialization="none" replace="instance" instance="testInstance" />
</xforms:model>

I tested it and the "language-instance" is written correctly and the "testInstance" does get the value from the scope...

But actually I don´t want the "testInstance" to be updated...
I want :
<xforms:instance id="resources-instance" src="oxf:/apps/2604/homepage/common/res-en.xml"
    xxforms:readonly="false"/>

the res-{en}.xml to be updated with the value hold by the language-instance.

Now I saw this:

<!-- XForms instance containing text resources -->
    <xforms:instance id="resources-instance" src="/forms/service/resources/{doc('input:instance')/*/form-id}/en"
                     xxforms:readonly="false"/>

    <!-- Update language submission -->
    <xforms:submission id="update-language-submission" serialization="none"
                       action="/forms/service/resources/{{xxforms:instance('parameters-instance')/form-id}}/{{instance('language-instance')}}" validate="false"
                       method="get" replace="instance" instance="resources-instance"
                       xxforms:readonly="false"/>



Is this possible, too?


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Changing language but a little bit easier than "forms-example"

fl.schmitt(ops-users)
hi Masen,

> Jeeeez! It´s working!!!!!!!! =) =)!!!!!! almost....

great :-)

> I tested it and the "language-instance" is written correctly and the
> "testInstance" does get the value from the scope...
>
> But actually I don´t want the "testInstance" to be updated...

Then you could change the get-lang submission to:

<xforms:submission id="get-lang" action="/2604/get" method="get"
serialization="none" replace="instance" instance="language-instance" />

>     <!-- Update language submission -->
>     <xforms:submission id="update-language-submission" serialization="none"
>                        
> action="/forms/service/resources/{{xxforms:instance('parameters-instance')/form-id}}/{{instance('language-instance')}}"
> validate="false"
>                        method="get" replace="instance"
> instance="resources-instance"
>                        xxforms:readonly="false"/>
>
> Is this possible, too?
i think so - you could try the following (i didn't test it...):

<xforms:submission
     id="update-language-submission"
     serialization="none"
action="oxf:/apps/2604/homepage/common/res-{{xxforms:instance('language-instance')}}.xml"

     validate="false"
     method="get"
     replace="instance"
     instance="resources-instance"
     xxforms:readonly="false"/>

This has the advantage that you don't need another XPL to read the ressources file.

If this submission works, you could make the workflow complete - read the
preferred language when the page loads, write it when the user changes it, and
update the ressources on languag e change.

HTH
florian


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Changing language but a little bit easier than "forms-example"

masjab-2
Hey Florian, 


i think so - you could try the following (i didn't test it...):

<xforms:submission
   id="update-language-submission"
   serialization="none"
action="oxf:/apps/2604/homepage/common/res-{{xxforms:instance('language-instance')}}.xml" 
   validate="false"
   method="get"
   replace="instance"
   instance="resources-instance"
   xxforms:readonly="false"/>

This has the advantage that you don't need another XPL to read the ressources file.

I was so happy....But this does not work...
The following error occurs:
2008-06-14 11:56:17,448 ERROR XFormsServer  - XForms - submission - xforms-submit-error throwable: org.orbeon.oxf.resources.ResourceNotFoundException: 
Cannot find resource /apps/2604/homepage/common/res-%7Bxxforms:instance('language-instance')%7D.xml?language=en

Does:
 
action="oxf:/apps/2604/homepage/common/res-{{xxforms:instance('language-instance')}}.xml" 

copy (if it was working)
oxf:/apps/2604/homepage/common/res-{{xxforms:instance('language-instance')}}.xml

into:

   replace="instance"
   instance="resources-instance"

my resources-instance?

That would be a dream...


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Changing language but a little bit easier than "forms-example"

fl.schmitt(ops-users)
hi Masen

>> <xforms:submission
>>    id="update-language-submission"
>>    serialization="none"
>> action="oxf:/apps/2604/homepage/common/res-{{xxforms:instance('language-instance')}}.xml"
>>    validate="false"
>>    method="get"
>>    replace="instance"
>>    instance="resources-instance"
>>    xxforms:readonly="false"/>

> I was so happy....But this does not work...
> The following error occurs:
> 2008-06-14 11:56:17,448 ERROR XFormsServer  - XForms - submission -
> xforms-submit-error throwable:
> org.orbeon.oxf.resources.ResourceNotFoundException:
> Cannot find resource
> /apps/2604/homepage/common/res-%7Bxxforms:instance('language-instance')%7D.xml?language=en

ok, it doesn't like the AVT-like syntax - i suppose there's one pair of curly
braces too much. Does the following work?

action="oxf:/apps/2604/homepage/common/res-{xxforms:instance('language-instance')}.xml"


> Does:
>  
>> action="oxf:/apps/2604/homepage/common/res-{{xxforms:instance('language-instance')}}.xml"
>
> copy (if it was working)
> oxf:/apps/2604/homepage/common/res-{{xxforms:instance('language-instance')}}.xml
>
> into:
>
>>    replace="instance"
>>    instance="resources-instance"
>
> my resources-instance?
yes, that's the idea behind it. The action URI is determined on runtime
depending on the content of the language instance. Documentation on AVTs:

http://www.orbeon.com/ops/doc/reference-xforms-2#avts

HTH
florian



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

form builder tutorial?

asianCoolz
is there any tutorial using the form builder ? article? video..?




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: form builder tutorial?

Erik Bruchez
Administrator
> is there any tutorial using the form builder ? article? video..?

Coming soon, but not yet!

-Erik

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Changing language but a little bit easier than "forms-example"

masjab-2
In reply to this post by fl.schmitt(ops-users)
Hey Florian, 

Am 14.06.2008 um 14:03 schrieb Florian Schmitt:

ok, it doesn't like the AVT-like syntax - i suppose there's one pair of curly braces too much. Does the following work?

action="oxf:/apps/2604/homepage/common/res-{xxforms:instance('language-instance')}.xml

You were right!

But still error-message:
2008-06-14 15:51:24,106 ERROR XFormsServer  - XForms - submission - xforms-submit-error throwable: org.orbeon.oxf.resources.ResourceNotFoundException: Cannot find resource /apps/2604/homepage/common/res-en.xml?language=en

But I feel, we are almost there..=)


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

create "save" buttion with builder

asianCoolz
In reply to this post by Erik Bruchez
i use builder and creted some simple form UI. i wanted to create "save" form feature. so i created a "insert" button.  Do i need to configurate "http services" ,"database services", "actions" , in order to create this feature? can explain what i should do.?"



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Changing language but a little bit easier than "forms-example"

fl.schmitt(ops-users)
In reply to this post by masjab-2
hi Masen,

>> action="oxf:/apps/2604/homepage/common/res-{xxforms:instance('language-instance')}.xml

> But still error-message:
> 2008-06-14 15:51:24,106 ERROR XFormsServer  - XForms - submission -
> xforms-submit-error throwable:
> org.orbeon.oxf.resources.ResourceNotFoundException: Cannot find resource
> /apps/2604/homepage/common/res-en.xml?language=en

i think this is caused by the method="get" attribute. I'm not sure which method
should be used here, but i think it's "post".

> But I feel, we are almost there..=)

that's true :-)

HTH
florian


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Changing language but a little bit easier than "forms-example"

fl.schmitt(ops-users)
In reply to this post by masjab-2
hi Masen,

> But still error-message:
> 2008-06-14 15:51:24,106 ERROR XFormsServer  - XForms - submission -
> xforms-submit-error throwable:
> org.orbeon.oxf.resources.ResourceNotFoundException: Cannot find resource
> /apps/2604/homepage/common/res-en.xml?language=en

as i said. i'm not sure about the correct syntax to load the ressource, but the
shopping cart example has the URI to load in the "resource" attribute, not in
the "action" attribute. So i think you have to use metho="get" resource="(as
above)".

HTH
florian



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Changing language but a little bit easier than "forms-example"

masjab-2
Hey, 

I´m not shure but I think it´s working....
Everytime I thought it´s working I found a new problem but this time it´s working!!!!

@Florian
THX to your help!!!
I thing without your help I would have tried for a month...

Here is what I did:

<xforms:model id="resources-model"
              xmlns:xs="http://www.w3.org/2001/XMLSchema"
              xmlns:xforms="http://www.w3.org/2002/xforms"
              xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
              xmlns:ev="http://www.w3.org/2001/xml-events">

    

    <xforms:action ev:event="xforms-ready"><xforms:send submission="get-lang"/></xforms:action>
    <xforms:action ev:event="xforms-ready"><xforms:send submission="update-language-submission"/></xforms:action>

    <xforms:instance id="language-instance">
        <language xmlns=""></language>
    </xforms:instance>

           

    <xforms:instance id="resources-instance" src="oxf:/apps/2604/homepage/common/res-en.xml"
    xxforms:readonly="false"/>

    

    <xforms:instance id="language">
        <language xmlns=""></language>
        </xforms:instance>

    

    <xforms:submission id="add-lang" action="/2604/add" ref="instance('language-instance')" method="post"  replace="none" />
    <xforms:submission id="get-lang" action="/2604/get" method="get" serialization="none" replace="instance" instance="language" />

    

    <xforms:submission
        id="update-language-submission"
        serialization="none"
        method="get"
        resource="/apps/2604/homepage/common/res-{xxforms:instance('language')}.xml" 
        validate="false"
        replace="instance"
        instance="resources-instance"
        xxforms:readonly="false"/>

    

</xforms:model>



There are now millions of more questions but I´ll start a new thread because I think I´m not alone with some of my question...=)
THX again...



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: create "save" buttion with builder

Erik Bruchez
Administrator
In reply to this post by asianCoolz
"Save" is a built-in functionality of Form Runner. I wouldn't create a  
service specifically for this, even though you could in theory write  
your own XForms code in the form to send your form somewhere else.

The best way in my opinion would be to implement your own persistence  
layer if you want to save your form to a different place.

-Erik

On Jun 14, 2008, at 6:59 PM, cw wrote:

> i use builder and creted some simple form UI. i wanted to create  
> "save" form feature. so i created a "insert" button.  Do i need to  
> configurate "http services" ,"database services", "actions" , in  
> order to create this feature? can explain what i should do.?"

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Changing language but a little bit easier than "forms-example"

Erik Bruchez
Administrator
In reply to this post by masjab-2
FYI we have now implemented two XForms extensions functions:

* xxforms:get-session-attribute()
* xxforms:set-session-attribute()

With this, you can, directly from XForms, save the current language  
into the user's session, and retrieve it later. We have now  
implemented this in Form Runner.

The documentation is under this section:

   http://www.orbeon.com/ops/doc/reference-xforms-2#orbeon-extensions

Maybe it is time to separate those functions into a separate  
documentation page.

-Erik

On Jun 11, 2008, at 11:10 AM, Masen J wrote:

> Hey,
> thanks for your help!!!
> But I am a newbie and maybe you can help me step by step..?
>
> 1) I think I´ll try to store the selection into eXist.
> ----but how?----
> Do I have to call a submission, when the selection1 was changed?
>
> 2) Is the xforms-ready-event used like in the book-cast example? I  
> remember that it was used to load init data...
>
> Please, maybe you can give me something like a "to-do" list...
>
> THX!!!!!!
>
>
>
> Am 11.06.2008 um 10:31 schrieb Florian Schmitt:
>
>> Masen,
>>
>>> Now I want a select1 to change the (label)language but it should  
>>> of course change in the whole app...
>>> 1) I create one language-model that holds the language
>>> 2) I put on every page an select1 to change the language defined  
>>> in 1
>>> 3) I create 2 xml files to hold the label in the specific language
>>
>> first, you will have to decide how to make the language selection  
>> persistent between the pages of your app. There are different ways,  
>> you could write the selection into the scope [1, 2] or save it into  
>> eXist.
>>
>> Then, you need a way to load the language file for the selected  
>> language. This could be done using an XPL that reads the persistent  
>> language selection (from eXist or using the scope generator), loads  
>> the language file respectively, and returns it. This could be done  
>> by a submission issued on the xforms-ready event.
>>
>> If the user changes the language, again a XPL could be called to:
>> - make the new choice persistent
>> - load the language file according to the new selection (this is  
>> the same as above, so the delegation processor could be used here).
>>
>> HTH
>> florian
>>
>> [1] http://www.orbeon.com/ops/doc/processors-serializers#scope-serializer
>> [2] http://www.orbeon.com/ops/doc/processors-generators#scope-generator
>>
>>
>>
>> --
>> You receive this message as a subscriber of the [hidden email]  
>> mailing list.
>> To unsubscribe: mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>
> --
> You receive this message as a subscriber of the [hidden email]  
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Changing language but a little bit easier than "forms-example"

masjab-2
THX Erik,

But I´m so glad that it´s working now (WITH LOTS OF FLORIANS HELP)  
that I am afraid to change it right now...

Still I have one(million =) ) questions..
I have a dictionary that can be edited as an administrator and users  
can do searches.
My search.xq does return the entries in the dictionary in a html page.
I wanted to implement something like a "own-vocabulary" that the user  
can store and export then...

Right now this should be "session-based" and I thought maybe I can use

> * xxforms:get-session-attribute()
> * xxforms:set-session-attribute()


to do this...

Do you think thats a good idea?
My entries are returned in a table and I thought of a checkbox and a  
"add to vocabulary" button so that the user can fill his vocabulary.

THX for your help!!!






--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
12