public function pushBindings(BlazeContext $context) { $requestUri = $context->getRequest()->getRequestURI()->getPath(); // remove the prefix of the url e.g. BlazeFrameworkServer/ if (!$requestUri->endsWith('/')) { $requestUri = $requestUri->concat('/'); } $requestUri = $requestUri->substring($context->getApplication()->getUrlPrefix()->replace('*', '')->length()); // Requesturl has always to start with a '/' if ($requestUri->length() == 0 || $requestUri->charAt(0) != '/') { $requestUri = new String('/' . $requestUri->toNative()); } foreach ($this->mapping as $navigationRule) { $regex = '/^' . str_replace(array('/', '*'), array('\\/', '.*'), $navigationRule->getMapping()) . '$/'; if ($requestUri->matches($regex)) { $bindingParts = $requestUri->substring(strlen($navigationRule->getMapping()) - 1)->split('/'); $count = count($bindingParts); $newValue = null; // Look for the bindings $binds = $navigationRule->getBindings(); for ($i = 0; $i < $binds->count(); $i++) { if ($i < $count && $bindingParts[$i] != '') { $newValue = $bindingParts[$i]; } else { $newValue = $binds->get($i)->getDefault(); } if ($newValue !== null) { $binds->get($i)->getReference()->setValue($context, $newValue); $newValue = null; } } } } }
/** * <p>Perform all state transitions required by the current phase of the * request processing {@link javax.faces.lifecycle.Lifecycle} for a * particular request. </p> * * @param context FacesContext for the current request being processed * @throws FacesException if a processing error occurred while * executing this phase */ public function execute(BlazeContext $context) { $oldViewId = $context->getRequest()->getSession(true)->getAttribute('blaze.view_restore'); if ($oldViewId != null) { $oldViewId = $oldViewId->getViewId(); } $actViewId = $context->getViewRoot()->getViewId(); $requestedView = $context->getViewHandler()->getRequestView($context); if (!$context->getDoRenderResponse() && !$context->getNavigated() && $oldViewId == $actViewId) { if ($requestedView == null) { $context->getResponse()->sendError(\blaze\netlet\http\HttpNetletResponse::SC_NOT_FOUND); $context->responseComplete(); } else { $requestedViewId = $requestedView->getViewId(); if ($requestedViewId != $actViewId) { $context->setViewRoot($requestedView); // clean up the el view scope $context->getELContext()->getContext(\blaze\web\el\ELContext::SCOPE_VIEW)->resetValues($context); } } } $context->getRequest()->getSession()->setAttribute('blaze.view_restore', $context->getViewRoot()); if (!$context->getResponseComplete()) { $context->getViewRoot()->processRender($context); } }
public function renderAttributes(\blaze\web\application\BlazeContext $context, \blaze\web\component\UIComponent $component) { $messages = $context->getMessages($component->getFor()); if (count($messages) > 0) { parent::renderAttributes($context, $component); } }
public function renderBegin(\blaze\web\application\BlazeContext $context, \blaze\web\component\UIComponent $component) { $writer = $context->getResponse()->getWriter(); $value = $component->getValue(); if ($value != null) { $writer->write($value); } }
public function renderChildren(\blaze\web\application\BlazeContext $context, \blaze\web\component\UIComponent $component) { if ($component->getUseMap() == true) { $writer = $context->getResponse()->getWriter(); $writer->write('<map name="' . $component->getClientId($context) . 'Map">'); parent::renderChildren($context, $component); $writer->write('</map>'); } else { parent::renderChildren($context, $component); } }
public function renderBegin(\blaze\web\application\BlazeContext $context, \blaze\web\component\UIComponent $component) { $writer = $context->getResponse()->getWriter(); $writer->write('<base'); $href = $component->getHref(); $target = $component->getTarget(); if ($href != null) { $writer->write(' href="' . $href . '"'); } if ($target != null) { $writer->write(' target="' . $target . '"'); } $writer->write('/>'); }
public function renderBegin(\blaze\web\application\BlazeContext $context, \blaze\web\component\UIComponent $component) { $writer = $context->getResponse()->getWriter(); $writer->write('<link rel="stylesheet" type="text/css" media="screen"'); $href = $component->getHref(); $charset = $component->getCharset(); if ($href != null) { $writer->write(' href="' . $href . '"'); } if ($charset != null) { $writer->write(' charset="' . $charset . '"'); } else { $writer->write(' charset="utf-8"'); } $writer->write('/>'); }
protected function setUp() { $test1 = new ATest(); $test1->setLabel(true); $test1->setName(10); $test1->setValue('MyValue1'); $test2 = new ATest(); $test2->setLabel('MyLabel2'); $test2->setName('value'); $test2->setValue($test1); $test3 = new ATest(); $test3->setLabel('label'); $test3->setName($test1); $test3->setValue('name'); $netApp = \blazeServer\source\netlet\NetletApplication::getAdminApplication(); $netlets = $netApp->getNetletContext()->getNetlets(); \ob_start(); // Need to do this because PHPUnit does something weird.. set_error_handler(array('blaze\\lang\\System', 'systemErrorHandler')); $this->markTestIncomplete('getClass() alsways fails because of Call to a member function getClass() on a non-object'); $app = $netlets->get('BlazeNetlet')->getClass()->getField('application')->get($netlets->get('BlazeNetlet')); $this->bCtx = new \blaze\web\application\BlazeContext($app, new \blazeServer\source\netlet\http\HttpNetletRequestImpl(), new \blazeServer\source\netlet\http\HttpNetletResponseImpl()); \ob_clean(); $this->bCtx = \blaze\web\application\BlazeContext::getCurrentInstance(); $this->bCtx->getELContext()->setContext(ELContext::SCOPE_REQUEST, new scope\ELRequestScopeContext(new \blaze\collections\map\HashMap())); $this->bCtx->getELContext()->getContext(ELContext::SCOPE_REQUEST)->set($this->bCtx, 'test1', $test1); $this->bCtx->getELContext()->getContext(ELContext::SCOPE_REQUEST)->set($this->bCtx, 'test2', $test2); $this->bCtx->getELContext()->getContext(ELContext::SCOPE_REQUEST)->set($this->bCtx, 'test3', $test3); }
public function renderBegin(\blaze\web\application\BlazeContext $context, \blaze\web\component\UIComponent $component) { $writer = $context->getResponse()->getWriter(); $type = $component->getType(); $writer->write('<script type="text/javascript">'); foreach ($component->getEffects() as $effect) { $id = $component->getParent()->getClientId($context); $writer->write('var listener = '); $effect->processRender($context); $writer->write(';'); $writer->write('var element = document.getElementById(\'' . $id . '\');'); // $writer->write('if(document.addEventListener) // element.addEventListener(\''.$type.'\', listener, false); // else // element.attachEvent(\'on'.$type.'\', listener);'); $writer->write('element.on' . $type . ' = listener;'); } $writer->write('</script>'); }
public function renderAttributes(\blaze\web\application\BlazeContext $context, \blaze\web\component\UIComponent $component) { $writer = $context->getResponse()->getWriter(); $id = $component->getClientId($context); $styleClass = $component->getStyleClass(); $style = $component->getStyle(); $title = $component->getTitle(); if ($id != null) { $writer->write(' id="' . $id . '"'); } if ($title != null) { $writer->write(' title="' . $title . '"'); } if ($styleClass != null) { $writer->write(' class="' . $styleClass . '"'); } if ($style != null) { $writer->write(' style="' . $style . '"'); } }
public function renderBegin(\blaze\web\application\BlazeContext $context, \blaze\web\component\UIComponent $component) { $writer = $context->getResponse()->getWriter(); $writer->write('<meta'); if ($component instanceof \blaze\web\component\html\ContentType) { $writer->write(' http-equiv="Content-Type" content="' . $component->getValue() . '; charset=' . $component->getCharset() . '"'); } else { if ($component instanceof \blaze\web\component\html\ContentLanguage) { $writer->write(' http-equiv="Content-Language" content="' . $component->getValue() . '"'); } else { if ($component instanceof \blaze\web\component\html\Keywords) { $writer->write(' name="keywords" content="' . $component->getValue() . '"'); } else { if ($component instanceof \blaze\web\component\html\Description) { $writer->write(' name="description" content="' . $component->getValue() . '"'); } } } } $writer->write('/>'); }
private function getValueFromContext($key) { $ctx = \blaze\web\application\BlazeContext::getCurrentInstance(); $key = \blaze\lang\String::asNative($key); $val = $this->context->getContext(ELContext::SCOPE_REQUEST)->get($ctx, $key); if ($val != null) { return $val; } $val = $this->context->getContext(ELContext::SCOPE_VIEW)->get($ctx, $key); if ($val != null) { return $val; } $val = $this->context->getContext(ELContext::SCOPE_SESSION)->get($ctx, $key); if ($val != null) { return $val; } $val = $this->context->getContext(ELContext::SCOPE_APPLICATION)->get($ctx, $key); if ($val != null) { return $val; } return null; }
public function renderBegin(\blaze\web\application\BlazeContext $context, \blaze\web\component\UIComponent $component) { $writer = $context->getResponse()->getWriter(); $writer->write('<script type="text/javascript">function commandLinkClick(link){ var parentForm=link.parentNode; while(parentForm.nodeName != "FORM"){ parentForm=parentForm.parentNode; } var identifier = document.createElement("input"); identifier.type="hidden"; identifier.name="BLAZE_COMMAND_IDENTIFIER"; identifier.value=link.id; parentForm.appendChild(identifier); parentForm.submit(); return false;} </script>'); $writer->write('<a'); }
private function getSession(\blaze\web\application\BlazeContext $context) { return $context->getRequest()->getSession(true); }
public function renderBegin(\blaze\web\application\BlazeContext $context, \blaze\web\component\UIComponent $component) { $writer = $context->getResponse()->getWriter(); parent::renderBegin($context, $component); $writer->write('<textarea'); }
private function renderOption(\blaze\web\application\BlazeContext $context, $id, $label, $selected, $disabled) { $writer = $context->getResponse()->getWriter(); $writer->write('<option'); $writer->write(' value="' . $id . '"'); if ($selected) { $writer->write(' selected="selected"'); } if ($disabled) { $writer->write(' disabled="disabled"'); } $writer->write('>'); $writer->write($label); $writer->write('</option>'); }
public function getRequestView(BlazeContext $context) { $requestUri = $context->getRequest()->getRequestUri()->getPath(); // remove the prefix of the url e.g. BlazeFrameworkServer/ if (!$requestUri->endsWith('/')) { $requestUri = $requestUri->concat('/'); } $requestUri = $requestUri->substring($context->getApplication()->getUrlPrefix()->replace('*', '')->length()); // Requesturl has always to start with a '/' if ($requestUri->length() == 0 || $requestUri->charAt(0) != '/') { $requestUri = new String('/' . $requestUri->toNative()); } foreach ($this->mapping as $navigationRule) { $regex = '/^' . str_replace(array('/', '*'), array('\\/', '.*'), $navigationRule->getMapping()) . '$/'; if ($requestUri->matches($regex)) { return $this->getView($context, $navigationRule->getIndexView()); } } return null; }
private function renderTableCell(\blaze\web\application\BlazeContext $context, \blaze\web\component\UIComponent $component, $parent, $head) { $writer = $context->getResponse()->getWriter(); if ($parent != null) { // $colspan = $parent->getSpan(); $styleClass = $parent->getStyleClass(); $style = $parent->getStyle(); if ($head) { $writer->write('<th'); } else { $writer->write('<td'); } // if ($colspan != null) // $writer->write(' colspan="' . $colspan . '"'); if ($styleClass != null) { $writer->write(' class="' . $styleClass . '"'); } if ($style != null) { $writer->write(' style="' . $style . '"'); } $writer->write('>'); $parent->processRender($context); $this->recursiveUnsetClientId($parent); if ($head) { $writer->write('</th>'); } else { $writer->write('</td>'); } } }
public function render(BlazeContext $context) { if (!$context->getResponseComplete()) { $this->response->doPhase($context, $this, $this->phaseListener); } }
public function processValueChange(ValueChangeEvent $event) { $this->expression->invoke(\blaze\web\application\BlazeContext::getCurrentInstance(), array($event)); }
/** * @param context the FacesContext for the current request * @return <code>true</code> if <code>FacesContext.responseComplete()</code> * or <code>FacesContext.renderResponse()</code> and the phase is not * RENDER_RESPONSE, otherwise return <code>false</code> * * @return boolean */ private function shouldSkip(BlazeContext $context) { if ($context->getResponseComplete()) { return true; } else { if ($context->getDoRenderResponse() && \blaze\web\event\PhaseId::RENDER_RESPONSE != $this->getId()) { return true; } else { return false; } } }
protected function invokeResolvedExpression(\blaze\web\el\Expression $expr = null, $args = null) { if ($expr == null) { return null; } if (!$expr->isValid()) { return $expr->getExpressionString(); } $context = \blaze\web\application\BlazeContext::getCurrentInstance(); $args = func_get_args(); array_shift($args); return $expr->invoke($context, $args); }
public function renderEnd(\blaze\web\application\BlazeContext $context, \blaze\web\component\UIComponent $component) { $writer = $context->getResponse()->getWriter(); $tag = $this->getTypeTag($component); if ($tag != null) { $writer->write('</' . $tag . '>'); } }
public function resetValues(\blaze\web\application\BlazeContext $context) { $sess = $context->getRequest()->getSession(true); $sess->setAttribute('blaze.web.el.scope.view', null); }
public function renderEnd(\blaze\web\application\BlazeContext $context, \blaze\web\component\UIComponent $component) { $writer = $context->getResponse()->getWriter(); $writer->write('/>'); }
public function processAction(ActionEvent $obj) { $this->expression->invoke(\blaze\web\application\BlazeContext::getCurrentInstance(), array($event)); }