JSF Backing Component - Composite Component - Stackoverflow Exception
I want to use a backing component as a layer for accessing the attributes
of my composite component (as defined in its interface). What I wanted to
achieve was reading the attributes of my componentent via my backing
component class where i give back the property value of the attribute
provided.
public String getName() {
if (this.name == null) {
this.name = getAttributes().get("name");
}
return this.name;
}
But when setting a new value e.g. via an input field I wanted to store the
value only within my backing bean properties not updating the values of
the original properties passed as attribute arguments to my composite
component.
public void setName(final String name) {
this.name = name;
}
My problem now is when the getter of my backing component is called the
first time or at some early stage of his life the code of the getter as
shown above results in a Stackoverflow exception as
getAttributes.get("name") calls the getter of my backing component
(itself) instead fetching the property/attribute provided to my composite
component. Fun part is using a simple getter only returning this.name
instead of calling getAttributes() I can set a breakpoint there and then
calling getAttributes.get("name") gives me not this.name but instead the
attribute provided to my composite component.
I guess it has something to do with the coupling betweend the backing
component and the composite component. That when the getter gets called
for the first time no coupling between them is given and therefor the call
of getAttributes.get("name") results in calling the getter of my backing
component whereas later the call does not invoke its own getter but
instead fetches the attribute provided to my comp component.
Anyone have any idea how to solve this issue? Thnx in advance.
Tuesday, 20 August 2013
Using an IF() based on a query result
Using an IF() based on a query result
I'm trying to use an IF() is mySQL where the structure looks something
like this:
if(
phone_number LIKE '%992%' (SELECT phone_number FROM db.phonebook WHERE
country='UK'),
SELECT xxx FROM xxx WHERE xxx,
SELECT xxx FROM xxx WHERE xxx
)
I'm trying to achieve:
IF (if you manage to find a phone number in the 'UK' phonebook that
looks like '992'),
THEN (run the following XXX query),
ELSE (run the following YYY query)
This doesn't work, the syntax is obviously wrong. Would appreciate you
advice.
I'm trying to use an IF() is mySQL where the structure looks something
like this:
if(
phone_number LIKE '%992%' (SELECT phone_number FROM db.phonebook WHERE
country='UK'),
SELECT xxx FROM xxx WHERE xxx,
SELECT xxx FROM xxx WHERE xxx
)
I'm trying to achieve:
IF (if you manage to find a phone number in the 'UK' phonebook that
looks like '992'),
THEN (run the following XXX query),
ELSE (run the following YYY query)
This doesn't work, the syntax is obviously wrong. Would appreciate you
advice.
Form does not submit any params
Form does not submit any params
Form does not submit any parameters. How can I fix it?
<form action="{{ path('search') }}" method="POST">
<div class="block-17">
<div class="block-17_1">
Êàòàëîã àâòîìîáèëåé
</div>
<div class="block-17_2">
<div class="block-17_2_1">
<span>Ïîèñê àâòîìîáèëåé</span>
<a href="">Ñðàâíèòü àâòîìîáèëè</a>
</div>
<div class="block-17_2_2">
<div>
<span class="block-17_2-name">Ìàðêà</span>
<div class="block-17_select-v1">
<select>
<option value="">Ëþáàÿ</option>
{% for manufacturer in manufacturers %}
<option value="{{ manufacturer.manufacturer }}">{{
manufacturer.manufacturer }}</option>
{% endfor %}
</select>
</div>
</div>
<div>
<span class="block-17_2-name">Ìîäåëü</span>
<div class="block-17_select-v1">
<select style="width: 100px">
<option value="">Ëþáàÿ</option>
</select>
</div>
</div>
<div>
<span class="block-17_2-name">Öåíà (ðóá.)</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for value in [500, 1000, 2000, 3000, 4000,
5000, 6000, 7000, 8000, 9000, 10000, 15000, 20000,
25000, 50000, 100000, 200000] %}
<option value="{{ value }}">{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="block-17_2-tire">
-
</div>
<div class="block-17_select-v2">
<select >
{% for value in [500, 1000, 2000, 3000, 4000,
5000, 6000, 7000, 8000, 9000, 10000, 15000, 20000,
25000, 50000, 100000, 200000] %}
<option value="{{ value }}">{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="clearboth">
</div>
</div>
</div>
<div class="clearboth">
</div>
</div>
<div class="clearboth">
</div>
</div>
<div class="block-17_3" id="block-17_3" style="overflow: hidden;">
<div class="block-17-hide">
<div class="block-17_3_1">
<span class="block-17_2-name">Îáúåì äâèãàòåëÿ (ë.)</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for value in [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4,
5, 6, 7] %}
<option value="{{ value }}">{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="block-17_2-tire">-</div>
<div class="block-17_select-v2">
<select>
{% for value in [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4,
5, 6, 7] %}
<option value="{{ value }}">{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="clearboth">
</div>
</div>
</div>
<div class="block-17_3_1">
<span class="block-17_2-name">Ìîùíîñòü äâèãàòåëÿ (ë. ñ.)</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for value in [50, 100, 150, 200, 250, 300, 400,
500, 600, 700] %}
<option value="{{ value }}">{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="block-17_2-tire">-</div>
<div class="block-17_select-v2">
<select>
{% for value in [50, 100, 150, 200, 250, 300, 400,
500, 600, 700] %}
<option value="{{ value }}">{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="clearboth">
</div>
</div>
</div>
<div class="block-17_3_1">
<span class="block-17_2-name">Êîðîáêà ïåðåäà÷</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for transmission in transmissions %}
<option value="{{ transmission.transmission
}}">{{ transmission.transmission }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="block-17_3_1">
<span class="block-17_2-name">Òèï äâèãàòåëÿ</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for engineType in engineTypes %}
<option value="{{ engineType.type }}">{{
engineType.type }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="clearboth clearboth-block-17_3">
</div>
<div class="block-17_3_1">
<span class="block-17_2-name">Òèï êóçîâà</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for body in bodies %}
<option value="{{ body.body }}">{{ body.body
}}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="block-17_3_1">
<span class="block-17_2-name">Ïðèâîä</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for transferCase in transferCases %}
<option value="{{ transferCase.transferCase
}}">{{ transferCase.transferCase }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="block-17_3_1" style="width: 145px">
<span class="block-17_2-name">Îïöèè</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select style="width: 145px">
{% for option in options %}
<option value="{{ option.equipment }}">{{
option.equipment }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="block-17_3_1" >
<span class="block-17_2-name">Ñòðàíà ïðèíàäëåæíîñòè</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for transferCase in transferCases %}
<option value="{{ transferCase.transferCase
}}">{{ transferCase.transferCase }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="clearboth">
</div>
<div></div>
<div class="block-17_hide_button_open">
<a onclick="openboxhidden('block-17_3'); return false"
href="#">Ñêðûòü äîïîëíèòåëüíûå ïàðàìåòðû</a>
</div>
</div>
</div>
<div class="clearboth">
</div>
<div class="block-17_4">
<input type="submit" value="Ïîèñê" name="" />
<a onclick="openboxhidden('block-17_3'); return false"
href="#">Ïîêàçàòü äîïîëíèòåëüíûå ïàðàìåòðû</a>
</div>
</div>
</form>
Form does not submit any parameters. How can I fix it?
<form action="{{ path('search') }}" method="POST">
<div class="block-17">
<div class="block-17_1">
Êàòàëîã àâòîìîáèëåé
</div>
<div class="block-17_2">
<div class="block-17_2_1">
<span>Ïîèñê àâòîìîáèëåé</span>
<a href="">Ñðàâíèòü àâòîìîáèëè</a>
</div>
<div class="block-17_2_2">
<div>
<span class="block-17_2-name">Ìàðêà</span>
<div class="block-17_select-v1">
<select>
<option value="">Ëþáàÿ</option>
{% for manufacturer in manufacturers %}
<option value="{{ manufacturer.manufacturer }}">{{
manufacturer.manufacturer }}</option>
{% endfor %}
</select>
</div>
</div>
<div>
<span class="block-17_2-name">Ìîäåëü</span>
<div class="block-17_select-v1">
<select style="width: 100px">
<option value="">Ëþáàÿ</option>
</select>
</div>
</div>
<div>
<span class="block-17_2-name">Öåíà (ðóá.)</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for value in [500, 1000, 2000, 3000, 4000,
5000, 6000, 7000, 8000, 9000, 10000, 15000, 20000,
25000, 50000, 100000, 200000] %}
<option value="{{ value }}">{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="block-17_2-tire">
-
</div>
<div class="block-17_select-v2">
<select >
{% for value in [500, 1000, 2000, 3000, 4000,
5000, 6000, 7000, 8000, 9000, 10000, 15000, 20000,
25000, 50000, 100000, 200000] %}
<option value="{{ value }}">{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="clearboth">
</div>
</div>
</div>
<div class="clearboth">
</div>
</div>
<div class="clearboth">
</div>
</div>
<div class="block-17_3" id="block-17_3" style="overflow: hidden;">
<div class="block-17-hide">
<div class="block-17_3_1">
<span class="block-17_2-name">Îáúåì äâèãàòåëÿ (ë.)</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for value in [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4,
5, 6, 7] %}
<option value="{{ value }}">{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="block-17_2-tire">-</div>
<div class="block-17_select-v2">
<select>
{% for value in [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4,
5, 6, 7] %}
<option value="{{ value }}">{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="clearboth">
</div>
</div>
</div>
<div class="block-17_3_1">
<span class="block-17_2-name">Ìîùíîñòü äâèãàòåëÿ (ë. ñ.)</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for value in [50, 100, 150, 200, 250, 300, 400,
500, 600, 700] %}
<option value="{{ value }}">{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="block-17_2-tire">-</div>
<div class="block-17_select-v2">
<select>
{% for value in [50, 100, 150, 200, 250, 300, 400,
500, 600, 700] %}
<option value="{{ value }}">{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="clearboth">
</div>
</div>
</div>
<div class="block-17_3_1">
<span class="block-17_2-name">Êîðîáêà ïåðåäà÷</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for transmission in transmissions %}
<option value="{{ transmission.transmission
}}">{{ transmission.transmission }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="block-17_3_1">
<span class="block-17_2-name">Òèï äâèãàòåëÿ</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for engineType in engineTypes %}
<option value="{{ engineType.type }}">{{
engineType.type }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="clearboth clearboth-block-17_3">
</div>
<div class="block-17_3_1">
<span class="block-17_2-name">Òèï êóçîâà</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for body in bodies %}
<option value="{{ body.body }}">{{ body.body
}}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="block-17_3_1">
<span class="block-17_2-name">Ïðèâîä</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for transferCase in transferCases %}
<option value="{{ transferCase.transferCase
}}">{{ transferCase.transferCase }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="block-17_3_1" style="width: 145px">
<span class="block-17_2-name">Îïöèè</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select style="width: 145px">
{% for option in options %}
<option value="{{ option.equipment }}">{{
option.equipment }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="block-17_3_1" >
<span class="block-17_2-name">Ñòðàíà ïðèíàäëåæíîñòè</span>
<div class="block-17_select-v2_outer">
<div class="block-17_select-v2">
<select>
{% for transferCase in transferCases %}
<option value="{{ transferCase.transferCase
}}">{{ transferCase.transferCase }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="clearboth">
</div>
<div></div>
<div class="block-17_hide_button_open">
<a onclick="openboxhidden('block-17_3'); return false"
href="#">Ñêðûòü äîïîëíèòåëüíûå ïàðàìåòðû</a>
</div>
</div>
</div>
<div class="clearboth">
</div>
<div class="block-17_4">
<input type="submit" value="Ïîèñê" name="" />
<a onclick="openboxhidden('block-17_3'); return false"
href="#">Ïîêàçàòü äîïîëíèòåëüíûå ïàðàìåòðû</a>
</div>
</div>
</form>
Monday, 19 August 2013
Creating a PHP PDO database class, trouble with the OOP
Creating a PHP PDO database class, trouble with the OOP
this is my current Database class:
class Database {
private $db;
function Connect() {
$db_host = "localhost";
$db_name = "database1";
$db_user = "root";
$db_pass = "root";
try {
$this->db = new PDO("mysql:host=" . $db_host . ";dbname=" .
$db_name, $db_user, $db_pass);
} catch(PDOException $e) {
die($e);
}
}
public function getColumn($tableName, $unknownColumnName,
$columnOneName, $columnOneValue, $columnTwoName = "1", $columnTwoValue
= "1") {
$stmt = $this->db->query("SELECT $tableName FROM
$unknownColumnName WHERE $columnOneName='$columnOneValue' AND
$columnTwoName='$columnTwoValue'");
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $results[0][$unknownColumnName];
}
}
I'm trying to run it using the following code:
$db = new Database();
$db->Connect();
echo $db->getColumn("Sessions", "token", "uid", 1);
And i get the following error:
PHP Fatal error: Call to a member function fetchAll() on a non-object in
/Users/RETRACTED/RETRACTED/root/includes/Database.php on line 19
Any idea what's up? Thanks
this is my current Database class:
class Database {
private $db;
function Connect() {
$db_host = "localhost";
$db_name = "database1";
$db_user = "root";
$db_pass = "root";
try {
$this->db = new PDO("mysql:host=" . $db_host . ";dbname=" .
$db_name, $db_user, $db_pass);
} catch(PDOException $e) {
die($e);
}
}
public function getColumn($tableName, $unknownColumnName,
$columnOneName, $columnOneValue, $columnTwoName = "1", $columnTwoValue
= "1") {
$stmt = $this->db->query("SELECT $tableName FROM
$unknownColumnName WHERE $columnOneName='$columnOneValue' AND
$columnTwoName='$columnTwoValue'");
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $results[0][$unknownColumnName];
}
}
I'm trying to run it using the following code:
$db = new Database();
$db->Connect();
echo $db->getColumn("Sessions", "token", "uid", 1);
And i get the following error:
PHP Fatal error: Call to a member function fetchAll() on a non-object in
/Users/RETRACTED/RETRACTED/root/includes/Database.php on line 19
Any idea what's up? Thanks
Navigating the Vertices on a Sphere Made of Triangles
Navigating the Vertices on a Sphere Made of Triangles
Pretty simple question: if I have a sphere made of triangles, how could I
differentiate the vertices and find the neighbors of a specific vertice?
Pretty simple question: if I have a sphere made of triangles, how could I
differentiate the vertices and find the neighbors of a specific vertice?
forced preemption on windows (occurs or not here)
forced preemption on windows (occurs or not here)
Sorry for my weak english, by preemption I mean forced context (process)
switch applied to my process.
My question is:
If I wrote and run my own program game in such way that it is 20
millisecond period work, then 5 millisecond sleep, and then windows pump
(peek message/dispatch message) in loop again and again - Is it ever
preempted by force in windows or no, this preemption doeas not occur ?
I suppose that this preemption would occur if i would not volountairy give
control back to system by sleep or peek/dispatch in by larger amount of
time - but here it will occur or no?
tnx for the answer
Sorry for my weak english, by preemption I mean forced context (process)
switch applied to my process.
My question is:
If I wrote and run my own program game in such way that it is 20
millisecond period work, then 5 millisecond sleep, and then windows pump
(peek message/dispatch message) in loop again and again - Is it ever
preempted by force in windows or no, this preemption doeas not occur ?
I suppose that this preemption would occur if i would not volountairy give
control back to system by sleep or peek/dispatch in by larger amount of
time - but here it will occur or no?
tnx for the answer
Returning view from jQuery AJAX get operation
Returning view from jQuery AJAX get operation
I'm trying to make an asynchronous jQuery get to an MVC Action to return a
view. For some reason, although it accesses the action, it does not render
the view.
This is the jQuery:
function showArchive(url) {
var moreRecentThanDate = $("#chooseDate").val();
$.get(url, { moreRecentThan: moreRecentThanDate });
}
and this is the action :
[HttpGet]
public ActionResult ShowArchive(DateTime moreRecentThan)
{
List<NewIndexViewModel> model = Service.GetArchives(moreRecentThan);
ViewBag.IsArchive = true;
return View("Index", model);
}
PS: I call this jQuery from an ad-hoc modal popup;
I'm trying to make an asynchronous jQuery get to an MVC Action to return a
view. For some reason, although it accesses the action, it does not render
the view.
This is the jQuery:
function showArchive(url) {
var moreRecentThanDate = $("#chooseDate").val();
$.get(url, { moreRecentThan: moreRecentThanDate });
}
and this is the action :
[HttpGet]
public ActionResult ShowArchive(DateTime moreRecentThan)
{
List<NewIndexViewModel> model = Service.GetArchives(moreRecentThan);
ViewBag.IsArchive = true;
return View("Index", model);
}
PS: I call this jQuery from an ad-hoc modal popup;
Subscribe to:
Posts (Atom)