cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dev at weitling <d...@weitling.net>
Subject Re: Further information needed on cform binding
Date Sun, 06 May 2007 22:30:24 GMT

> I think that I understand your case but I don't know where is the
> problem. It's quite complicated situation for binding and runtime of a
> form but CForms are able to manage it, surely.

I'm sure about CForms being able to handle it, but not sure about me ;-)

> I guess that you will need to write your own binding or on-change
> handlers (or both) but they will not be much troublesome.

Yes, but I want to keep it as clean as possible.

> First, you must realize that you are dealing with
> semi-three-dimensional table. One dimension is number of languages,
> second is number of question-anwsers sets and third is number of
> answers. Since rendering three-dimensional tables is rather tricky you
> will need... five repeaters ;-)

Hah! I'm here with three repeaters. And it's not just a table but a tree
structure with connections between its nodes and leafs...

> QL must be simple repeater with on-change handler that updates
> questions and answers repeaters according to the changes performed on
> QL by user. Next, you will need question+answers repeater that holds
> as row pair of question and answers. Question is just simple repeater
> that have a row for each language (rendered as column, though).
> Answers is repeater that have a row for each answer. Answer, similarly
> to the question, is repeater that holds answer for each language.

My project is about multiple choice questions. For that there's a lot of
answers (which may be false) and localized text for the question and the
answers.
My code till now is as follows:

class Question {
  int id;
  Collection questionDatas, questionLocales, answers;
}
class QuestionData {
  int questionID, questionLocaleID;
  String data; // the text
}
class QuestionLocale {
  int id, questionID;
  String locale;
  Collection answerDatas;
}
class Answers {
  int id, questionID;
  Collection answerDatas;
}
class AnswerData {
  int answerID, questionLocaleID;
  String data; // the text
}

    <fb:repeater id="questionLocaleRepeater" parent-path="."
row-path="questionLocales">
        <fb:identity>
            <fb:value id="questionLocale" path="locale"/>
        </fb:identity>
       
        <fb:on-bind>
            <fb:value id="questionData" path="questionData/data"/>
        </fb:on-bind>
    </fb:repeater>
   
    <fb:repeater id="answerRepeater" parent-path="." row-path="answers">
        <fb:identity>
            <fb:value id="answerID" path="id"/>
        </fb:identity>
       
        <fb:on-bind>
            <fb:value id="answerCorrect" path="correct"/>               
               

            <!--
                now here's the point: I want to access and compare the
id of the answers/id with questionLocales/answerDatas/answerID
                but switching the path means cutting the branch I'm
sitting on. If I only could use a kind of variable holding the current id
                the answerRepeater...
             -->
            <fb:repeater id="localeAnswerRepeater" parent-path="."
row-path="/questionLocales/answerDatas[./answerID=/answers/id]">
                <fb:on-bind>
                    <fb:value id="answerData" path="data"/>
                </fb:on-bind>
            </fb:repeater>
        </fb:on-bind>
           
    </fb:repeater>

> Yeah, rendering five repeaters in HTML nicely will demand some of your
> own rendering by is doable. Hope that this helps a little. If not,
> explain what is exact problem, please.

Sorry, if I complicate it too much. Tomorrow is a new day!

Bye and thanks,
Florian

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message